[Math] Interpolation of 3 points

interpolation

I want to interpolate a function given 3 $x$ points ($0$, $0.5$ and $1$) and their correspondent $y$ values. $x$ values will be always between $0$ and $1$.

How can I interpolate a given value, like $0.3$? And what about if I add more sample data, can I improve the interpolation accuracy?

Example

This is the problem I'm trying to solve: in a football fantasy game each player has an associated price $y$. Each player value is calculated from a quality factor, $x$, a value from $0$ to $1$, where $0$ is a poor-performance player and $1$ is a top level player. Given that quality factor, the price would be calculated interpolating the value from this data:

| $x$ | $y$ |

| $0$ | lowest price in database |

| $0.5$ | average price in database |

| $1$ | highest price in database |

So, given $y(0)=10$, $y(0.5)=75$ and $y(1)=100$ we have this chart:

sample chart


I found this solution using WolframAlpha

$2. a x^2 – 3. a x + a – 4. b x^2 + 4. b x + 2. c x^2 – c x$

Where $a$ is low price, $b$ average price and $c$ expensive price.

Best Answer

For a low number of points, you can use polynomial interpolation as given by the Lagrange formula (https://en.wikipedia.org/wiki/Lagrange_polynomial). For three points, you get a quadratic expression, corresponding to a parabola.


Lagrange's formula works for any number of points, but quickly becomes unstable for larger $n$ (do not exceed, say, $n=10$). A better alternative is piecewise polynomial interpolation, such as cubic splines (https://en.wikipedia.org/wiki/Spline_interpolation).