[Math] An equation to map values from one range to another

algebra-precalculus

I need a formula (preferably something I can write with JavaScript, so simple arithmetic) that will map my value that is between 0.5 and 1, to a new value between 0 and 1. My brain is dead, this seems trivial, yet I can't say I ever learned how to do this. I'm sure someone here can help!

.5 => 0
.6 => .2
.7 => .4
.8 => .6
.9 => .8
1 => 1

Update

I found this answer which is excellent for linear mappings! My linear mapping equation is $y=2x-1$

And what if I wanted something non-linear?

.5 => 0
.75 => .25
.875 => .5
1 => 1

Best Answer

Would a polynomial function work for you? If so, just construct the Lagrange or Newton-form interpolating polynomial. If you don't know how to do this, WolframAlpha has an interpolating polynomial calculator: http://www.wolframalpha.com/examples/Polynomials.html.

Related Question