# cbloom rants

## 11/11/2007

### 11-11-07 - 1

Hmm. So, I've often used this rough approximation that gamma on monitors is pretty close to 2.0 , so you can just use square and sqrt to degamma and regamma. Well, sqrt is kind of annoying. So what if you approximate sqrt(x) under the constraints that the approximation is exact at 0 and 1 ? For a quadratic you must have something in the form f(x) = { x + c*x*(1-x) }. This is a cool form, the first term gives us the endpoints f(0) = 0 and f(1) = 1 , and the second term gives us the curve to try to match the sqrt. Now we can minimize the error over the interval {0,1}. If we minimize by integrating in dx we get c = 0.92857. But that's sort of wrong because x is in linear light space which is not what we see, we see more like gamma, which would mean integrating in even steps of y, so if we integrate instead using dy, we get c = 1.03125 Well, guess what's in between? c=1. So a pretty okay approximation is f(x) = 2*x - x*x. This is a rad approximation because it can be done without even any constants.

BTW the inverse is x = 1 - sqrt(1-y)