# Non-proportional, inverse algorithm

I'm trying to come up with the correct algorithm for a setting on a meter in my app.

Basically, I have a value (lets call it 'x') returned from a source which can be in the range of 0 to 30.

As x goes from 30 to 0, I need y (the output of the algorithm) to go from 0 to 1.0. Basically, as x gets smaller, y needs to get larger but the rates of each are not proportional.

-
There are infinitely many solutions to your problem. For instance, the dependence might be quadratic, cubic, general polynomial, or exponential. Take your pick! – dtldarek Jun 24 '12 at 23:19
Is there some underlying physical connection between the meter reading and what it is reading? That might suggest an appropriate model? – copper.hat Jun 24 '12 at 23:37

There are many possible answers: $$y = 1 - \left(\frac{x}{30}\right)^k$$ or $$y = \left(\frac{30- x}{30}\right)^k$$ for some positive value of $k$ would each do what you ask: you might experiment. If $k=1$ then the relationship is linear.