All I know how to do is plug recipes into beersmith
. It pretty much computes everything. I would like to figure it all out by hand, but at this point it is low on my list of things to figure out.
You can get a free trial version online. If you plan on designing beers or even keeping a recipe book this is a great way to do it. And, it is only $20, or 21, or something quite cheap for what you get.
This probably wasn't the answer you wanted so hopefully someone else can help you with the formula.