# Max and min of $f(x)=\sin^2{x}+\cos{x}+2$.

My first try was to look for when $\cos{x}$ and $\sin{x}$ attain their min and max respectively, which is easy using the unit circle. So the minimum of $\sin{x}+\cos{x}$ has maximum at $\sqrt{2}$ and minimum at $-\sqrt{2}.$ But if the sine-term is squared, how do I find the minimum of $\sin^2{x}+\cos{x}$?

I then tried the differentiation method:

$$f'(x)=2\sin{x}\cos{x}-\sin{x}=(2\cos{x}-1)\sin{x}=0,$$

which in the interval $(0,2\pi)$, gave me the the roots $\left(\frac{\pi}{2},\frac{3\pi}{2},\frac{\pi}{3},\frac{5\pi}{3}\right)$. So

$$f(\pi/2)=3, \quad f(3\pi/2)=3, \quad f(\pi/3)=\frac{13}{4}, \quad f(5\pi/3)=\frac{13}{4}.$$

So $f_{\text{max}}=\frac{13}{4}$ and $f_{\text{min}}=3.$ But the minimum should be $1$.

• You're missing $\pi$ as a root – iamwhoiam Sep 2 '17 at 10:17
• Are we interested in all solutions or just solutions in the interval $[0, 2\pi)$? – N. F. Taussig Sep 2 '17 at 10:51
• The derivative is not equal to zero when $x = \frac{\pi}{2}$ or when $x = \frac{3\pi}{2}$. You want $\sin x = 0$, not $\cos x = 0$. – N. F. Taussig Sep 2 '17 at 10:55

Credit to @iamwhoiam for suggesting this solution.

There's nothing wrong with your method - you just missed a root. When you find the roots of the first derivative, either $2 \cos x - 1$ or $\sin x$ should equal $0$, so we have:

First case: $2 \cos x - 1 = 0$, $\cos x = \frac{1}{2}$. Since $\cos(x)$ is an even function, $\cos(x) = \cos(-x)$. Since we know that one solution is $x = \frac{\pi}{3}$, $x$ can also be $\frac{5\pi}{3}$.

Second case: $\sin x = 0, \pi$. Using the properties of $\sin x$ we know these are the only solutions in the range $[0,2\pi)$.

Therefore the solutions in the range $[0, 2\pi)$ are: $x = 0, \frac{\pi}{3}, \frac{5\pi}{3}, \pi$. Substituting each in the original equation gives $3, \frac{13}{4}$, $\frac{13}{4}$ and $1$ respectively. The minimum of these critical points is $1$, which is the minimum value of the original function.

• You meant the solutions in the domain $[0, 2\pi)$. – N. F. Taussig Sep 2 '17 at 10:33
• What's the difference between $(0,2\pi)$ and $[0,2\pi)$? – Toby Mak Sep 2 '17 at 10:34
• The interval $(0, 2\pi)$ does not contain $0$, while $[0, 2\pi)$ does. – N. F. Taussig Sep 2 '17 at 10:34

Hint: $\sin^2(x)=1-\cos^2(x)$. You will get a quadratic equation in $u=\cos(x)$.

HINT: write $f(x)$ as $$f(x)=1-\cos(x)^2+\cos(x)+2=-\cos(x)^2+\cos(x)+3=-\left(\cos(x)^2-\cos(x)+\frac{1}{4}\right)+\frac{13}{4}=-\left(\cos(x)-\frac{1}{2}\right)^2+\frac{13}{4}$$

• This clearly means that max is $13/4$. The minimum will be attained when $\cos{x}=1$, which means that the last expression in your answer can be simplified to $$-(1-1/2)^2 + 13/4 = 13/4 - 1/4 = 3.$$, but this is wrong. The min value of the function is $1$. – Parseval Sep 2 '17 at 10:27
• where is the mistake? and what do you mean? – Dr. Sonnhard Graubner Sep 2 '17 at 10:38
• @Parseval The calculation is accurate. You can find the maxima by finding the values at which $\cos x = \frac{1}{2}$. Observe that the minimum occurs when $\cos x = -1$. – N. F. Taussig Sep 2 '17 at 10:41

Set $t=\cos x$. Then $$\sin^2x+\cos x+2=1-\cos^2x+\cos x+2=3+t-t^2$$ is a quadratic polynomial $P(t)$, which has a global maximum for $t=\dfrac12$, and this maximum is equal $$P\Bigl(\dfrac12\Bigr)=\dfrac{13}4.$$ Now we have to find the minimum of $P(t)$ on the interval $[-1,1]$. As this function is symmetric w.r.t. $\;x=\dfrac12$, the minimum is attained at $t=-1$, and it is equal to $\;P(-1)=1.$

As per your work $$f'(x)=2\sin{x}\cos{x}-\sin{x}=(2\cos{x}-1)\sin{x}=0,$$ now either $(2\cos{x}-1)=0$ then ${x}={\pi/3,5\pi/3}$
or $\sin{x}=0$ then ${x}={\pi}$
for ${x}={\pi}$ value of f(${\pi}$) =1 which is minimum value of function.