How do I determine the maximum value for a quadratic equation on an interval?

4.2k Views Asked by At

I need to determine the maximum value for y = ax^2 + bx + c, where I know the coefficients and the upper and lower x values.

Say the input values are:

  • a = 5
  • b = 1
  • c = 2
  • x lower limit = -5
  • x upper limit = 5

Given these input, how do I determine the the maximum value for the quadratic equation above?

My goal is to implement a function in a computer programming language that has a signature such as funcMax(int a, int b, int c, int xUpper, int xLower). The part that is confusing me is that I have two x values for this signature but one x in the formula above.

But computer programming aside for now, mathematically, how do I get the max value for the above equation, using the above input (with two x values)?

2

There are 2 best solutions below

0
On BEST ANSWER

For this quadratic function, the global maximum happens either at the two ends or at a local maximum.

The first two cases are simple, you have to only compare the $y$ evaluated at the upper and lower limits of $x$ respectively.

And there is a local maximum only if the $a$ value is negative, shown by the second derivative test. When this is the case, the maximum value is given by taking $x = -\frac b{2a}$. (You can verify this by completing square or first derivative test.) Then you have to check if this $x$ is within your domain given by the upper and lower limits.

If I write your required function out:

$$\begin{align*}&\text{funcMax}(a,b,c,x_{Upper}, x_{Lower}) \\ =& \begin{cases} \max(ax_{Upper}^2 + bx_{Upper}+c, ax_{Lower}^2 + bx_{Lower}+c,\frac{b^2}{4a}-\frac{b^2}{2a}+c) & \text{if }a\ne0\text{ and }x_{Upper}\le-\frac{b}{2a}\le x_{Lower}\\ \max(ax_{Upper}^2 + bx_{Upper}+c, ax_{Lower}^2 + bx_{Lower}+c) & \text{otherwise} \end{cases}\end{align*}$$

0
On

In effect, you would like to determine the maximum value of the function $f \colon [-5,5] \to \mathbf{R}$ defined as $$ f(x):= 5x^2+x+2$$ for all $x$ in $[-5,5]$. We can do this using the methods of calculus as follows:

The function $f$ is continuous on $[-5,5]$ and differentiable on $(-5,5)$. Differentiate $f$, we find that $$f^\prime(x) = 10x+1. $$ Thus $f^\prime = 0$ for $x=-1/10$ only; whereas $f^\prime < 0$ for $x < -1/10$ so that $f$ is a decreasing function on the interval $(-\infty,-1/10]$; and $f^\prime > 0 $ for $x > -1/10$ so that $f$ is an increasing function on the interval $[-1/10, +\infty)$.

Thus it follows that $f(-5) > x > f(-1/10)$ for all $x$ such that $-5< x < -1/10$; in other words, $f(-5) = 5 \cdot (-5)^2 + (-5) + 2 = 122 \geq f(x) $ for all $x$ in the interval $[-5,-1/10]$.

Similarly, $f(5) = 132 \geq f(x) $ for all $x$ in the interval $[-1/10,5]$.

Hence the maximum value of the given quadratic is $132$ when $x=5$.