<s>[INST] 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$

 [/INST] 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}$$
</s>