[Math] Fitting a quadratic polynomial to two points such that it is always concave downward

polynomialsquadratics

Given two points $(x_1, y_1)$ and $(x_2, y_2)$, I'd like to construct a quadratic polynomial of the form $y = a_2x^2 + a_1x + a_0$ such that it intersects both points and is concave downward (i.e., has a global maximum but no minimum). The maximum does not have to occur between the two points.

Since two points are not sufficient to fully determine a quadratic system, I'm currently setting $a_0 = 0$ and computing $a_2$ and $a_1$ as follows:

$$a_2 = \frac{x_2y_1 – x_1y_2}{x_1^2x_2 – x_1x_2^2}$$

(The $a_2$ formula is derived by solving $y_1 = a_2x_1^2 + \frac{x_1}{x_2}(y_2 – a_2x_2^2)$ for $a_2$.)

$$a_1 = \frac{y_1 – a_2x_1^2}{x_1}$$

This produces a quadratic polynomial that passes through both points, but does nothing to ensure that it is always concave downward.

This problem is similar to the one answered here, except that the slopes at the two points are unspecified, although the following situations are possible:

  • Both slopes are positive
  • Both slopes are negative
  • The slope at point 1 is positive and the slope at point 2 is negative.

However, I'm unsure of how to apply these constraints; I don't know how inequalities – as opposed to equalities, as in the aforementioned question – involving the derivative could be applied in this case.

Any assistance would be appreciated!

Best Answer

Try using

$$ p(x) = -x^2 + a_1 x + a_0. $$

Taking the first coefficient to be $-1$ (or any other negative number) ensures that the parabola is concave down. Then one just needs to solve the equations

$$ p(x_1) = y_1 \qquad \text{and} \qquad p(x_2) = y_2 $$

for $a_1$ and $a_0$, yielding

$$ a_0 = \frac{x_1 x_2^2 - x_1^2 x_2 + x_1 y_2 - x_2 y_1}{x_1 - x_2}, $$

$$ a_1 = \frac{x_1^2 - x_2^2 + y_1 - y_2}{x_1-x_2}. $$

Related Question