Maximum value of a function. I am not able to check double derivative. Can someone explain me how $\sin^p x \cos^q x$ attains maximum at $\tan^2 x = \frac pq$.
I am not able to check whether double derivative is positive or negative.

Question
Show that $$\sin^p\theta\cos^q\theta$$ attains a maximum when $$\theta=\tan^{-1}\sqrt{(p/q)}$$
Solution
Ley $y=\sin^p\theta\cos^q\theta$. For a maximum or minimum of $y$, we have $\frac{\text dy}{\text dx}=0$
\begin{align}p\sin^{p-1}\theta\cos^{q+1}\theta-q\sin^{p+1}\theta\cos^{q-1}\theta&=0\\
\sin^{p-1}\theta\cos^{q-1}\theta(p\cos^2\theta-q\sin^2\theta)&=0\end{align}
Therefore \begin{align}\sin\theta&=0\\
&\Downarrow\\
\theta&=0\\
\text{or } \cos\theta&=0\\
&\Downarrow\\
\theta&=\frac \pi 2\\
\text{or }\tan^2\theta&=\frac pq\\
&\Downarrow\\
\theta&=\tan^{-1}\sqrt{p/q}\end{align}
Now $y=0$ at $\theta=0$ and also at $\theta=\frac\pi2$
When $0<\theta<\frac\pi2$, $y$ is positive
Also, $\tan^{-1}\sqrt{p/q}$ is the only value of $\theta$ lying between $0$ and $\frac \pi2$ at which $\frac{\text d}{\text dx}=0$.
Hence $y$ is maximum when $$\theta=\tan^{-1}\sqrt{p/q}$$
This can be seen from the graph of $y$

 A: Your picture shows a proof that $f'(x)=0$ at $x=x_0=\arctan\sqrt{p/q}$.
As $p$, $q\ge1$, $0<x_0<\pi/2$. Think of the graph of $f$ on $(0,\pi/2)$:
$f(0)=f(\pi/2)=0$ and $f(x)>0$ if $0<x<\pi/2$. Then $f$ certainly has
a maximum in the open interval $(0,\pi/2)$. But the calculation
in the picture shows the only turning point is at $x_0$. So $f$
has a maximum at $x_0$. You don't need to consider $f''(x_0)$.
A: When you want to maximize $Sin^p x Cos^q x$ you can equally maximize $Sin^{2p} x Cos^{2q} x$ so ,suppose we need to maximize $$f=Sin^{2p} x Cos^{2q} x=\\
(Sin^2 x)^ (Cos^2x)^q $$ 
we know $$sin^2x+cos^2x=1 $$ so ,put down $cos^2x=1-sin^2x$ in $f$
$$f=(Sin^2 x)^p (Cos^2x)^q=(Sin^2 x)^p (1-in^2x)^q=X^pY^q$$with $$X+Y=1$$ now ,take f'
$$f=X^p(1-X)^q \to \\f'=pX^{p-1}(1-X)^{q}-qX^{p}(1-X)^{q-1}=0\\
X^{p-1}(1-X)^{q-1}(p(1-X)-qX)=0\\$$form here $$X=0,1,\frac{p}{p+q}$$
$0,1$ does not make maximum $f(0)=0,f(1)=0$ so $f(\frac{p}{p+q})$ is max,
when you return to begining ,you will see $$X=sin^2 x=\frac{p}{p+q}$$ so find $$cos^2x=1-X=1-\frac{p}{p+q}=\frac{q}{p+q}$$ and finally $$tan^2x=\frac{sin^2x}{cos^2x}=\frac{\frac{p}{p+q}}{\frac{q}{p+q}}=\frac{p}{q}$$
A: You don't have to check the second derivate. What you use is:
$$y(0) = \sin^p(0)\cos^q(0) = 0$$
$$y(\pi/4) = \sin^p(\pi/4)\cos^q(pi/4) = 2^{-p/2-q/2} > 0$$
$$y(\pi/2) = \sin^p(\pi/2)\cos^q(pi/2) = 0$$
So you see that $y$ must have a maximum for some $c\in[0,\pi]$ and it has to be at least $2^{-(p+q)/2}>0$ so it's not at the end points which means that $y'(c) = 0$ and there's only one point where this holds so there must be the maximum.
A: This is a nice application of logarithmic differentiation.
Consider $$f=\sin^p(x) \cos^q(x)\implies \log(f)=p \log(\sin(x))+q  \log(\cos(x))$$ Differentiate both sides $$\frac{f'}f=p \cot(x)-q \tan(x)=\frac{p-q \tan^2(x)}{\tan(x)}$$ and then the conditions for an extremum as already given in answers.
But, we need to check the second derivative : start with $$f'=f \left(\frac{f'}f \right)$$ and differentiate using the product rule $$f''=f'\left(\frac{f'}f\right)+f \left(\frac{f'}f \right)'$$ But, at the extremum $f'=0$ which reduces the problem to the sign of $$f \left(\frac{f'}f \right)'=-f\,(p \csc ^2(x)+q \sec ^2(x))$$
Edit
If you want to continue with some fun, using $$\sin(\tan^{-1}(t))=\frac{t}{\sqrt{t^2+1}}\qquad \cos(\tan^{-1}(t))=\frac{1}{\sqrt{t^2+1}}$$ and replacing $t$ by $\sqrt{\frac{p}{q}}$ the maximum value of $f$ is given by $$f_{max}=\sqrt{\frac{p^p \, q^q}{(p+q)^{(p+q)}}}$$
As said in comments, this works for any value of $p>0$, $q>0$, $p$ and $q$ being integers, rational or non rational numbers.
Considering the case where $p+q=k$, using again logarithmic differentiation we should find that $$\frac{f'_{max}}{f_{max}}=\frac 12 \log \left(\frac{p}{k-p}\right)$$ which is positive if $p>\frac k 2$ and negative otherwise.
A: For simplicity, I'll assume that both $p$ and $q$ are at least 1.  (Note that if $q = -1$ and $p = 1$, then your function is $\tan x$ and does not have a maximum!)
You first take the derivative,
$$ p\sin^{p-1} x\cos^{q+1}x - q\sin^{p+1}x\cos^{q-1}x = sin^{p-1}x\cos^{q-1}x(p\cos^{2}x - q\sin^{2}x).$$
Setting the last part equal to zero, we have that either
$\sin^{p-1}x = 0$, $\cos^{q-1}x = 0$ or $\tan^{2}x = \frac{p}{q}$.
It follows that the inputs that satisfy $\sin^{p-1}x = 0$ and $\cos^{q-1}x = 0$ do not yield a maximum.  (With this input, your output for the function would be zero and there are inputs that yield positive values.)
So we are left with $\tan^{2}x = \frac{p}{q}$.
Since we have the theorem that if an input is a local maximizer, it must be a critical point, and we ruled out the other cases, then the local maximizer must be a solution to the above equation.  (Note that it is possible that there are solutions to the above equation that are not maximizers.)
Finally, invoking the fact that your function is periodic allows us to say that the local maximizer is a global maximizer.
A: Let $f(x) = \sin^{p}(x) \, \cos^{q}(x)$ then
\begin{align}
f'(x) &= f(x) \, (-q \, \tan(x) + p \, \cot(x)) \\
&= -q \, \cot(x) \, f(x) \, \left( \tan^{2}(x) - \frac{p}{q} \right)
\end{align}
Now, the maximum of a function is defined by $f'(x) = 0$ then, seeking values other than $f(x) = 0$,
$$\tan^{2}(x) = \frac{p}{q}$$
or 
$$x_{max} = \tan^{-1}\left(\sqrt{\frac{p}{q}}\right).$$
