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!

  • 1
    $\begingroup$ Try using $-x^2 + a_1 x + a_0$ instead. $\endgroup$ May 21 '14 at 19:20
  • $\begingroup$ Good suggestion, @Antonio; it worked. If you'd like to propose this as an answer I'll accept it. $\endgroup$ May 22 '14 at 16:03

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}. $$


Suppose that $y_2>y_1$ and $x_1\neq x_2$. Note that this is not too burdensome; if $x_1=x_2$ there is no solution; if $y_2<y_1$ you reverse the two points; if $y_2=y_1$ it's not too hard to solve. Then consider


You now choose $a,b$ to pass through the two points you want. To pass through $(x_2,y_2)$ you need $b=y_2$. To pass through $(x_1,y_1)$ you need $y_1=-a(x_1-x_2)^2+y_2$, which rearranges to $$a=-\frac{y_1-y_2}{(x_1-x_2)^2}$$

Since $y_2>y_1$, we must have $a>0$ so it is indeed a parabola, and points downward.

  • $\begingroup$ Thanks for the solution, vadim123. However, I prefer the approach Antonio Vargas proposed as it doesn't require the points to be switched if $y_2 < y_1$ (thus avoiding the need for this to be checked). $\endgroup$ May 22 '14 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.