Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|cite|improve this question
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.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.