Let $f(x)=(p\sec(x))^2 + (q\csc(x))^2$
Now,$f(x)=(p\sec(x) - q\csc(x))^2+2p\sec(x)q\csc(x)$
Now, $(p\sec(x) - q\csc(x))^2\geq0$ and has minimum value = $0$ when $p\sec(x) = q\csc(x) \implies \tan(x)=\frac{q}{p} $
The minimum value of $f(x)$ will be
$2p\sec(x)q\csc(x)$ where $\tan(x)=\frac{q}{p} $
$=\frac{4pq}{\sin(2x)} =2(p^2+q^2)$
or directly putting the value $\tan(x)$, $p^2(1+\frac{q^2}{p^2})+ q^2(1+\frac{p^2}{q^2})=2(p^2+q^2)$
Again, $f(x)=(p\sec(x))^2 + (q\csc(x))^2 =p^2+q^2+ (p\tan(x))^2 + (q\cot(x))^2$
$(p\tan(x))^2 + (q\cot(x))^2 = (p\tan(x) - q\cot(x))^2+2pq $ will have minimum value $2pq$ for $\tan^2(x)=\frac{q}{p}$
Clearly, here the minimum value of $f(x)=p^2+q^2+2pq = (p+q)^2$
When I used derivative test, I reached the last value.
To rephrase the question, let h(x)=$(p\tan(x))^2 + (q\cot(x))^2$ =>f(x)=$p^2+q^2$+h(x)
As calculated above,
the minimum value of f(x)=$2(p^2+q^2)$
and the minimum value of h(x)=2pq
The minimum value of f(x) should have been $p^2+q^2+2pq$.
In general, $(p+q)^2\neq 2(p^2+q^2)$ unless $p=q$.
Where have I gone wrong?