Demo on max--min

Max--min problem with a function of one variable

Let's consider the max-min problem with f[x] a 5th degree polynomial,
f[x] = 9.29-13.96 x-0.498 (x^2)+10.37 (x^3)-5.9` (x^4)+(x^5).
Let's find the max and min of f[x] on the interval [1, 2].

f[x_] := 9.29-13.96 x-0.498 (x^2)+10.37 (x^3)-5.9` (x^4)+(x^5)

f[x]

Plot[f[x], {x, 1, 2}]

The endpoints are always candidates for max and min, so we evaluate f[x]  at x = 1 and x = 2.

f[1]

f[2]

The critical points are points in the interior of the interval where the derivative of f is zero or does not exist.  Our f is a polynomial, so is differentiable everywhere.  Therefore, we are only looking for places where f'[x] = 0.  

f'[x] is a fourth degree polynomial,  so solving f'[x] = 0 is not something you know how to do "by hand".
For now, we are going to use Mathematica's equation solving capacity, and later we will consider some techniques for solving equations ourselves (with the help of a calculator or computer.)

f'[x]
NSolve[f'[x]==0, x]

There are 4 solutions to f'[x] = 0,  but we are only interested in the 2 solutions in the interval (1, 2).    We evaluate f[x] at those two points.

f[x]/.x->1.3715592243173533`

f[x]/.x->1.741179449817073`

According to our terminology (which differs from that in the text)  the function f on the domain [1, 2] has a global (and local) max at x = 1 with maximum value .302  has global (and local) min at x = 1.3716  approximately,  with min value   -0.06304,  approximately,   has a local max at approximately  x = 1.7411 with local max value about -0.0108 and has a local min at the endpoint x = 2 with local min value -0.062.