z# Maximum/Minimum
A function $f$ has an *absolute maximum* at $c$ if $f(c) >= f(x)$. We call $f(c)$ the maximum value of $f$.
The absolute **maximum** is the largest possible output value for a function.

A function $f$ has an absolute minimum at $c$ if $f(c) <= f(x)$. $f(c)$ is the absolute minimum value of $f$.
The absolute **minimum** is the smallest possible output value for a function.

- Where the derivative of a function is zero, there is either a peak or a trough.

# Critical Numbers
A number is considered critical if the output of a function exists and $\dfrac{d}{dx}$ is zero or undefined.

# Local Max/Min
A local max/min is a peak or trough at any point along the graph.

# Extreme Value Theorem
If $f$ is a continuous function in a closed interval $[a, b]$, then $f$ achieves both an absolute maximum and an absolute minimum in $[a, b]$. Furthermore, the absolute extrema occur at $a$ or at $b$ or at a critical number between $a$ and $b$.

## Examples
> Find the absolute maximum and absolute minimum of the function $f(x) = x^2 -3x + 2$ on the closed interval $[0, 2]$:

1. $x=0$ and $x=2$ are both critical numbers because they are endpoints. Endpoints are *always* critical numbers because $\dfrac{d}{dx}$ is undefined.
2. $\dfrac{d}{dx} x^2 -3x + 2 = 2x -3$
3. Setting the derivative to zero, $0 = 2x - 3$
4. Solving for x, we get $x = \dfrac{3}{2}$. Three halves is a critical number because $f'(\dfrac{3}{2})$ is $0$. 
5. Now check the outputs for all critical numbers ($f(x)$ at $x = \{0, 2, \dfrac{3}{2}\}$)
6. $f(0) = 0^2 -3(0) + 2 = 2$
7. $f(2) = 2^2 - 3(2) + 2) = 0$
8. $f(\dfrac{3}{2}) = (\dfrac{3}{2})^2 - 3(\dfrac{3}{2}) + 2 = -\dfrac{1}{4}$
9. The minimum is the lowest of the three, so it's $-\dfrac{1}{4}$ and it occurs at $x = \dfrac{3}{2}$ 
10. The maximum is the highest of the three, so it's $2$ at $x = 0$.


> Find the absolute maximum and absolute minimum of the function $h(x) = x + 2cos(x)$ on the closed interval $[0, \pi]$.

 1. $x = 0$ and $x = \pi$ are both critical numbers because they are endpoints. Endpoints are critical because $\dfrac{d}{dx}$ is undefined.
 2. $\dfrac{d}{dx} x + 2\cos(x) = 1 - 2sin(x)$ 
 3. Setting that to zero, we get $0 = 1 - 2\sin(x)$
 4. $\sin(x) = \dfrac{1}{2}$ 
 5. In the interval $[0, \pi]$, $\sin(x)$ has a value of $\dfrac{1}{2}$ in two places: $x = \dfrac{\pi}{6}$ and $x = \dfrac{5\pi}{6}$. These are both critical numbers because they are points where $\dfrac{d}{dx}$ is zero.
 6. Now we plug these values into the original function:
 7. $h(0) = 0 + 2\cos 0 = 2$
 8. $h(\pi) = \pi + 2\cos(\pi) = \pi - 2 \approx 1.14159$
 9. $h(\dfrac{\pi}{6}) = \dfrac{\pi}{6} + 2\cos(\dfrac{\pi}{6}) = \dfrac{\pi}{6} + 2(\dfrac{\sqrt{3}}{2} = \dfrac{\pi}{6} + \sqrt{3} \approx 2.2556$ 
 10. $h(\dfrac{5\pi}{6}) = \dfrac{5\pi}{6} + 2\cos(\dfrac{5\pi}{6}) = \dfrac{5\pi}{6} - \sqrt{3} \approx 0.88594$
