I am trying to use a parabola to interpolate between 3 values and I have been struggling with finding an equation that works for me.
The constraints are:
- passes through the points $(0, s), (x,m), (1, n)$ [$x$ is not given, but must be between $0$ and $1$]
- $0 < s < 1$
- $0 < m < 1$
- $0 < n < 1$
- $0 < x < 1$
- $x$ is the x-coordinate of the maximum/minimum of the parabola
- $m > s$ and $m > n$ or $m < s$ and $m < n$ ($m$ will never be between $s$ and $n$)
In the standard $y = ax^2 + bx + c$ form, I have been able to determine:
- $c = s$
- $a + b + c = n$
- $c - \frac{b^2}{4a} = m$
- $n - s = a + b$
- $a = \frac{b^2}{ 4*(s - m)}$
I always seem to come out with 2 possible values for $b$ (due to a $\pm \sqrt{...}$), and only one of those will give me a maximum/minimum between $0$ and $1$. I am almost certain that there is a way to determine $a$, $b$, and $c$ from the given $s$, $n$, and $m$.
I have been slamming my head against a wall for the past week and a half trying to figure this out.
EDIT: I have gotten the equation to a point where all I need to do is calculate $a$ from the inputs $s$,$n$, and $m$.
If you want a vertical parabola $\;f(x)=y=ax^2+bx+c\;$ then it may be easier. Since $\;(0,s)\;$ is on it, we get $\;s=f(0)=c\;$ ,and also:
$$n=f(1)=a+b+c=a+b+s\implies a+b=n-s$$
and since $\;(x_0,m)\;$ (changed the notation for convenience) is the parabola's vertex, we get that
$$\begin{cases}x_0=-\frac b{2a}\\{}\\m=-\frac{\Delta}{4a}=-\frac{b^2-4ac}{4a}=-\frac{b^2}{4a}+s\end{cases}$$
Solving the above
$$b=-2ax_0\implies m=-\frac{4a^2x_0^2}{4a}+s=-ax_0^2+s\implies a=\frac{s-m}{x_0^2}$$
and you have all your parabola's coefficient in function of the given points.