Make a formula that gets a value and outputs another one

47 Views Asked by At

Invent a formula that asks for an input value and outputs a different value based on the input. The minimum input is 140, maximum input is 600. Here is some data that the formula should be based on.

140 input = 0.03 output
200 input = 0.42 output
328 input = 0.15 output
457 input = 0.1 output
586 input = 0.05 output
600 input = 0.03 output
1

There are 1 best solutions below

0
On BEST ANSWER

Use polynomial interpolation to find a polynomial of degree $5$ or lower that matches all six points. I computed this polynomial in Octave (I rather used a least squares polynomial fit, which matches interpolation when the degree is the number of points minus one, anyway): $$f(x)= 8.4063\times 10^{-13} x^5 -1.8485\times 10^{-9} x^4 +1.5552\times 10^{-6} x^3 \\ -6.1930\times 10^{-4} x^2 +0.11456 x -7.4723.$$ Those teeny tiny coefficients for the bigger powers are not negligible since the $x$ values are quite huge ($\sim 10^3$) and the degree is $5$ ($x^5 \sim 10^{15}$).

Edit: The change of variable $y:= x/100$ (that is, $x=100y$) makes the coefficients look nicer: $$f(100y)= 8.4063\times 10^{-3} y^5 -0.18485 y^4 +1.5552 y^3 \\ -6.1930 y^2 +11.456 y -7.4723.$$