Finding maximum of a given function 
Show that $f(x)=\sin x(1+\cos x)$ attains its maximum at $x= \pi/3$.

I differentiated the function $f$ and got $f'(x)=\cos x(1+2\cos x)$. After equating with $0$, I got $x=\pi/2$ and $x =\pi/3 + n\pi$ with $n\neq 0$. So I did not get $x= \pi/3$ even as an extreme value.
 A: Probably your differentiation is not correct,
$$f(x)=\sin x(1+\cos x)$$
$$f'(x)=\sin x\frac{d}{dx}(1+\cos x)+(1+\cos x)\frac{d}{dx}\sin x$$
$$=\sin x(-\sin x)+(1+\cos x)\cos x$$
$$=-\sin^2 x+\cos x+\cos^2 x$$
$$=2\cos ^2x+\cos x-1$$
$$=(2\cos x-1)(\cos x+1)$$
$$\implies f''(x)=-4\sin x\cos x-\sin-1$$
for maximum value, setting $f'(x)=0$
$$(2\cos x-1)(\cos x+1)=0$$
$$2\cos x-1=0\ \ \ \text{Or} \ \ \ \cos x+1=0$$
$$\cos x=\frac12\ \ \ \text{Or} \ \ \ \cos x=-1$$
$$\cos x=\cos \frac{\pi}{3}\ \ \ \text{Or} \ \ \ \cos x=\cos \pi$$
$$x=2n\pi\pm\frac{\pi}{3}\ \ \ \text{Or} \ \ \ \ x=2n\pi\pm\pi$$
$$x=\ldots, -\frac{5\pi}{3}, -\frac{\pi}{3}, \frac{\pi}{3}, \frac{5\pi}{3}, \ldots\ \ \ \text{Or} \ \ \ \ x=\ldots, -3\pi,-\pi, \pi, 3\pi, \ldots$$
Now, setting $x=\pi/3$ in $f''(x)$, we get
$$f\left(\frac{\pi}{3}\right)=-4\sin\frac{\pi}{3}-\sin\frac{\pi}{3}-1$$
$$\implies f\left(\frac{\pi}{3}\right)=-2\sqrt3-\frac{\sqrt3}{2}-1<0$$
hence the function $f(x)=\sin x(1+\cos x)$ is maximum at $x=\frac{\pi}{3}$
A: You need to solve
$$\cos x(1+\cos x)-\sin x\sin x=2\cos^2x+\cos x-1=0.$$
The roots are $\cos x=-1,\dfrac12$, so that $\sin x=0,\pm\dfrac{\sqrt3}2$.
The corresponding function values are
$$0,\pm\dfrac{3\sqrt3}4.$$
Hence the maximum is achieved by
$$(\cos x,\sin x)=\left(\frac12,\frac{\sqrt3}2\right).$$
A: Note that, if $f(x)=\sin(x)\bigl(1+\cos(x)\bigr)$, then$$f'(x)=\cos(x)+\cos^2(x)-\sin^2(x)=\cos(x)+2\cos^2(x)-1.$$In order to solve the equation $f'(x)=0$, let $t=\cos(x)$. So, you have to solve the equation $2t^2+t-1=0$. It has two solutions: $-1$ and $\frac12$. And $\cos(x)=\frac12$ when $x=\frac\pi3$. Besides $f''\left(\frac\pi3\right)=-\frac{2\sqrt3}2$. Can you take it from here?
A: $$\cos x(1+2\cos x)=0$$
$$\cos x=0\ \ \ \text{or} \ \ 1+2\cos x=0$$
$$x=\frac{(2n+1)\pi}{2}\ \ \ \text{or} \ \ \cos x=-\frac12$$
$$x=\frac{(2n+1)\pi}{2}\ \ \ \text{or} \ \ \cos x=\cos\frac{2\pi}{3}$$
$$x=\frac{(2n+1)\pi}{2}\ \ \ \text{or} \ \ \ x=2n\pi\pm\frac{2\pi}{3}$$
$$x=\ldots, -\frac{\pi}{2}, \frac{\pi}{2}, \frac{3\pi}{2}\ldots \ \ \ \text{or} \ \ \ x=\ldots, -\frac{4\pi}{3}, -\frac{2\pi}{3}, \frac{2\pi}{3}, \frac{4\pi}{3}, \ldots $$
