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

Here is a really dumb question, but I cannot find answers on Google for some reason or other. All the answers seem to be buried under mounds of percent difference formulas (which is not what I am asking).

I am trying to generate a value between two variables based on a percentage.

$$\begin{align*} 0\% &= X \qquad \text{(the minimum value)}\\\\ 50\% &= \frac{X + Y}{2}\\\\ 100\% &= Y\qquad \text{(the maximum value)} \end{align*}$$

What would the formula be?

share|cite|improve this question
Readers, it might be useful to know that this is essentially the lerp() function, which stands for linear interpolation. I figured this out after a little under a month that I posted. – Joshua Lamusga Sep 2 '13 at 7:57
up vote 2 down vote accepted

$$X+(\text{percent here})\cdot(Y-X)$$ So for example,

$X+(25\%)\cdot(Y-X)$ is $25$ percent of the way to $Y$, from $X$.

share|cite|improve this answer

The formula for "$t$ percent", where $t$ is any number between $0$ and $100$, is $$\left(1-\frac{t}{100}\right)X+\left(\frac{t}{100}\right)Y$$

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.