After 39 years, I finally use the quadratic equation
17 January 2009 10:56 am UTC
When I was in high school, my buddies had a simple test to tell when we’d had too much to drink. If you could could recite the quadratic equation, you could have another beer.
Whether the test kept us sober I can’t recall, but it did drill the incantation into my memory: “negative b plus or minus the square root of b squared minus four a c all over two a.”
If I ever knew what you would use the equation for, it quickly faded along with a thousand facts like the population of Guyana, retained only for the duration of a geography test. Over the years, though, I’ve caught myself checking my mental state by reciting the quadratic equation, so those words stuck, like the first stanza of “O Captain My Captain.”
Yesterday I needed to convert a linear scale to a logarithmic scale. I’d set up an NSSlider control that allowed the user to select values between 0 and 1. I wanted to weight the values so that the halfway value would be .75 instead of .5, the three-quarters value would be .95, and so on.
After some trial and error I found that I could get the logarithmic scale I wanted by taking the slider’s value x and running it through this formula:
y = x + x * (1.0 – x)
That’s exactly what I wanted: the slider values 0, .1, .2, .3, .4 .5,.6, .7, .8, .9, and 1.0 came out as 0, .19, .36, .51, .64, .75, .84, .91, .96, .99, and 1.0.
Then it dawned on me that I also had to perform that operation in reverse.
At first I was totally bewildered. I tried rewriting my little formula to get x on one side by itself so I could solve for it. No luck. y = x * (2.0 – x), y = 2x – x squared, -y = x squared – 2x; I just couldn’t come up up a solvable expression.
Then I remembered the quadratic equation.
Hmm. I tinkered with my formula and got it into the form 0 = x squared – 2x + y. Aha! In the quadratic equation, a would be 1 (the value that you multiply times x squared), b would be 2, and c would be my y value. I could then solve the quadratic equation and get x.
A little tinkering with the quadratic equation reduced it to this: x = -(((square root of (4.0 – (4.0 * y) )) – 2.0) / 2.0). Imagine my joy when I plugged in the logarithmic y values I had calculated earlier and got the linear x values.
I learned the quadratic equation as a sophomore in high school. That was thirty-nine years ago. I’d never encountered a practical application for it until yesterday. I guess high school taught me useful things after all.
Now, excuse me while I go look up the population of Guyana.
Leave a Comment
There are no comments for this article.