I have this equation.
2⌈C / E⌉ + C ≤ S + 2
I need to find the largest integer C satisfying the equation given S and E. I proceeded to "solve" the equation for C (math below is wrong):
Starting Point: 2⌈C / E⌉ + C ≤ S + 2
Multiply by E: 2⌈C⌉ + CE ≤ (S + 2) / E
Factor C: C(2 + E) ≤ (S + 2) * E
"Solution": C ≤ (S + 2) * E / (2 + E)
This doesn't work, and I know why. Multiply by E results in 2E⌈C/E⌉ which is not the same as 2⌈C⌉. (The factor C step is correct even though it looks wrong but that doesn't help.)
I kind of face an impasse here. I need to break up ⌈C/E⌉ and I don't see how to do it.
Stack exchange suggests How to isolate a variable inside floor and ceiling functions? which looks like the same thing, but equation is too complex and the answer too terse to be digestible.
A mathematical solution defeated me; however I was able to find an algorithmic solution.
Replacing 2E⌈C/E⌉ with 2C is wrong; but introduces a maximum error of E. So I just push C back through the original equation, see if it's larger than S + 2, if so, subtract the difference between S + 2 and the total from C. Due to the way the error acts, this never affects the result of the 2E⌈C/E⌉ portion of the calculation, and therefore always takes the correct amount off the other term (which is just C).