Answer
The absolute maximum is $f(\frac{\pi}{6}) = \frac{\pi}{6}+\sqrt{3}$
The absolute minimum is $f(-\pi) = -\pi-2$
$f(\frac{\pi}{6}) = \frac{\pi}{6}+\sqrt{3}$ is a local maximum.
$f(\frac{5\pi}{6}) = \frac{5\pi}{6}-\sqrt{3}$ is a local minimum.
Work Step by Step
$f(x) = x + 2~cos~x$
Note that this function is continuous on the interval $[-\pi,\pi]$ and differentiable on the interval $(-\pi,\pi)$.
We can find the points where $f'(x) = 0$:
$f'(x) = 1-2~sin~x = 0$
$sin~x= \frac{1}{2}$
$x = \frac{\pi}{6}, \frac{5\pi}{6}$
We can verify the values of the function when $f'(x) = 0$ and at the endpoints of the interval $[-\pi,\pi]$:
$f(-\pi) = (-\pi) + 2~cos~(-\pi) = -\pi-2 \approx -5.14$
$f( \frac{\pi}{6}) = ( \frac{\pi}{6}) + 2~cos~( \frac{\pi}{6}) = \frac{\pi}{6}+\sqrt{3} \approx 2.26$
$f(\frac{5\pi}{6}) = (\frac{5\pi}{6}) + 2~cos~(\frac{5\pi}{6}) = \frac{5\pi}{6}-\sqrt{3} \approx 0.89$
$f(\pi) = (\pi) + 2~cos~(\pi) = \pi-2 \approx 1.14$
The absolute maximum is $f(\frac{\pi}{6}) = \frac{\pi}{6}+\sqrt{3}$
The absolute minimum is $f(-\pi) = -\pi-2$
$f(\frac{\pi}{6}) = \frac{\pi}{6}+\sqrt{3}$ is a local maximum.
$f(\frac{5\pi}{6}) = \frac{5\pi}{6}-\sqrt{3}$ is a local minimum.