\(tan^2x+cot^2x=2=2.tanx.cotx\)
\(\Leftrightarrow tan^2x+cot^2x-2tanx.cotx=0\)
\(\Leftrightarrow\left(tanx-cotx\right)^2=0\Leftrightarrow tanx=cotx=\dfrac{1}{tanx}\)
\(\Leftrightarrow tanx=\pm1\)
\(P=\dfrac{1}{cosx}-\dfrac{cosx}{1+sinx}=\dfrac{1+sinx-cos^2x}{cosx\left(1+sinx\right)}=\dfrac{sin^2x+sinx}{cosx\left(1+sinx\right)}\)
\(=\dfrac{sinx\left(1+sinx\right)}{cosx\left(1+sinx\right)}=tanx=\pm1\)