# Complex math equation

I was wondering if someone could help me figure out an equation for:

I want to scale a double (between 8-13) to be from 0 - 100.
So 8 will be 0, 9 will be 20, 13 will be 100, 12.5 will be 90 and so on.

I hope that makes sense and would appreciate if someone could help.

y = 20*x - 160

Well, you have a range of 5 and you want to scale that to a range of 100, so you’ll need to multiply by 20. You want to start at 8 though, so you need to subtract 8 * 20.

output = 20*input - 160

Thanks Ether and Connor!

You should know the general process for figuring this out, just in case your situation changes and you want a new formula.

You want:
y = m * x + b

and you want this to be true for x=8 -> y=0, and for x=13 -> y=100.

So, you have two equations to solve for two variables:
0 = m * 8 + b
100 = m * 13 + b

If you subtract the first equation from the second, the b terms will cancel out:
100 = m * (13 - 8)
100 = m * 5
20 = m

Substitute 20 into either of the equations (the first is easier):
0 = 20 * 8 + b
b = -160

I hope this is helpful. When I saw the thread title “Complex math equation”, I thought we were going to discuss real and imaginary numbers. A math geek gets easily excited…

Just use the two-point formula:

y = y1+(x-x1)/(x2-x1)*(y2-y1)

with x1=8, x2=13, y1=0, y2=100 this gives y = 20*(x-8)

or plot your data in Excel

8,0
9,20
12.5,90
13,100

to see the shape, and then

click on “add trendline” and select an appropriate model (linear in this case) to fit (and it will give you the equation)
*
*