# Find the absolute maximum and minimum values of the function f given by

Question:

Find the absolute maximum and minimum values of the function f given by

$f(x)=\cos ^{2} x+\sin x, x \in[0, \pi]$

Solution:

$f(x)=\cos ^{2} x+\sin x$

$f^{\prime}(x)=2 \cos x(-\sin x)+\cos x$

$=-2 \sin x \cos x+\cos x$

Now, $f^{\prime}(x)=0$

$\Rightarrow 2 \sin x \cos x=\cos x \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}$ as $x \in[0, \pi]$

Now, evaluating the value of $f$ at critical points $x=\frac{\pi}{2}$ and $x=\frac{\pi}{6}$ and at the end points of the interval $[0, \pi]$ (i.e., at $x=0$ and $x=\pi$ ), we have:

$f\left(\frac{\pi}{6}\right)=\cos ^{2} \frac{\pi}{6}+\sin \frac{\pi}{6}=\left(\frac{\sqrt{3}}{2}\right)^{2}+\frac{1}{2}=\frac{5}{4}$

$f(0)=\cos ^{2} 0+\sin 0=1+0=1$

$f(\pi)=\cos ^{2} \pi+\sin \pi=(-1)^{2}+0=1$

$f\left(\frac{\pi}{2}\right)=\cos ^{2} \frac{\pi}{2}+\sin \frac{\pi}{2}=0+1=1$

Hence, the absolute maximum value of $f$ is $\frac{5}{4}$ occurring at $x=\frac{\pi}{6}$ and the absolute minimum value of $f$ is 1 occurring at $x=0, \frac{\pi}{2}$, and $\pi$.