>>newrgross = g / ((g-(g *r))/g)
>>
>>Maybe some math types can simplify that, but I think it will work
Sure, here is the simplification. The original formula:
g / ((g-(g*r))/g)
Put the last g into the numerator:
g^2 / (g-g*r)
Take out the factor g, from numerator and denominator:
g / (1-r)
Which is the formula Sergey indicated.
The derivation of the simpler formula is as follows. When we have pay a tax, have a discount, etc. on a known number, we take, for example, 5% away (r = 0.05), and keep 95% (1 - 0.05) of the original amount. So we basically multiply the known (higher) amount by 0.95. If it is the lower (discounted) amount we know, we proceed the opposite way - and the opposite of multiplication is division - so you simply divide by 0.95 (or (1-r)). This can easily be proved with algebra, but I'll omit that part for now.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)