Find the maximum and the minimum values of the function $f\left(x\right) = \sin x + \cos x$, $x \in \left[0,2\pi\right]$
$f\left(x\right) = \sin x + \cos x$
$\therefore$ $f'\left(x\right) = \cos x - \sin x$
For maxima or minima, $f'\left(x\right) = 0$
i.e. $\cos x - \sin x = 0$
i.e. $\sin x = \cos x$
i.e. $\tan x =1$
i.e. $x = \dfrac{\pi}{4} + k \pi$ where $k \in Z$
Since $x \in \left[0,2\pi\right]$, $f'\left(x\right) = 0$ $\implies$ $x = \dfrac{\pi}{4}, \; \dfrac{5\pi}{4}$
Now, $f''\left(x\right) = -\sin x - \cos x$
$\therefore$ $f''\left(\dfrac{\pi}{4}\right) = - \sin \left(\dfrac{\pi}{4}\right) - \cos \left(\dfrac{\pi}{4}\right) = -\dfrac{1}{\sqrt{2}}-\dfrac{1}{\sqrt{2}} = -\sqrt{2} < 0$
$\implies$ $f\left(x\right)$ has local maximum at $x=\dfrac{\pi}{4}$ and $f\left(\dfrac{\pi}{4}\right)= \sqrt{2}$
$f''\left(\dfrac{5\pi}{4}\right) = - \sin \left(\dfrac{5\pi}{4}\right) - \cos \left(\dfrac{5\pi}{4}\right) = \dfrac{1}{\sqrt{2}}+\dfrac{1}{\sqrt{2}} = \sqrt{2} > 0$
$\implies$ $f\left(x\right)$ has a local minimum at $x = \dfrac{5\pi}{4}$ and $f\left(\dfrac{5\pi}{4}\right) = -\sqrt{2}$
For global maximum and minimum values consider $f\left(0\right)$ and $f\left(2\pi\right)$
Now, $f\left(0\right) = \sin 0 + \cos 0 = 1$
$f\left(2\pi\right) = \sin \left(2\pi\right) + \cos \left(2\pi\right) = 1$
Now $f\left(\dfrac{\pi}{4}\right) = \sqrt{2}$, $f\left(\dfrac{\pi}{2}\right) = 1$, $f\left(\dfrac{3\pi}{4}\right) = 0$, $f\left(\pi\right) = -1$, $f\left(\dfrac{5\pi}{4}\right) = -\sqrt{2}$, $f\left(\dfrac{3\pi}{2}\right) = -1$, $f\left(\dfrac{7\pi}{4}\right) = 0$
$\therefore$ Global maximum occurs at $x = \dfrac{\pi}{4}$ and global maximum $= f\left(\dfrac{\pi}{4}\right) = \sqrt{2}$
Global minimum occurs at $x = \dfrac{5\pi}{4}$ and global minimum $= f \left(\dfrac{5\pi}{4}\right) = -\sqrt{2}$