Find the absolute maximum and minimum values of the function of given by
$f(x)=\cos ^{2} x+\sin x, x \in[0, \pi]$
Given : $f(x)=\cos ^{2} x+\sin x$
$\Rightarrow f^{\prime}(x)=2 \cos x(-\sin x)+\cos x=-2 \sin x \cos x+\cos x$
For a local maximum or a local minimum, we must have
$f^{\prime}(x)=0$
$\Rightarrow-2 \sin x \cos x+\cos x=0$
$\Rightarrow \cos x(2 \sin x-1)=0$
$\Rightarrow \sin x=\frac{1}{2}$ or $\cos x=0$
$\Rightarrow x=\frac{\pi}{6}$ or $\frac{\pi}{2}$ $[\because x \in(0, \pi)]$
Thus, the critical points of $f$ are $0, \frac{\pi}{6}, \frac{\pi}{2}$ and $\pi$.
Now,
$f(0)=\cos ^{2}(0)+\sin (0)=1$
$f\left(\frac{\pi}{6}\right)=\cos ^{2}\left(\frac{\pi}{6}\right)+\sin \left(\frac{\pi}{6}\right)=\frac{5}{4}$
$f\left(\frac{\pi}{2}\right)=\cos ^{2}\left(\frac{\pi}{2}\right)+\sin \left(\frac{\pi}{2}\right)=1$
$f(\pi)=\cos ^{2}(\pi)+\sin (\pi)=1$
Hence, the absolute maximum value when $x=\frac{\pi}{6}$ is $\frac{5}{4}$ and the absolute minimum value when $x=0, \frac{\pi}{2}, \pi$ is $1 .$