Prove that $\frac{dy}{dx}+\sec^2(\frac{\pi}{4}-x)=0$ 
If $y=\sqrt{\frac{1-\sin 2x}{1+\sin 2x}}$, prove that $\frac{dy}{dx}+\sec^2(\frac{\pi}{4}-x)=0$

My attempts:
Attempt 1:
$y=\sqrt{\frac{1-\sin 2x}{1+\sin 2x}}$
$\implies y=\sqrt{\frac{\sin^2 x+\cos^2 x-2\sin x \cos x}{\sin^2 x+\cos^2 x+2\sin x \cos x}}$
$\implies y=\sqrt{\frac{(\sin x -\cos x)^2}{(\sin x+\cos x)^2}}$
$\implies y=\frac{\sin x -\cos x}{\sin x +\cos x}$
$\therefore \frac{dy}{dx}=\frac{(\sin x +\cos x)(\cos x+\sin x)-(\sin x -\cos x)(\cos x -\sin x)}{(\sin x +\cos x)^2}$ 
$\implies \frac{dy}{dx}=\frac{(\sin x+\cos x)^2+(\sin x -\cos x)^2}{(\sin x+\cos x)^2}$
$\implies \frac{dy}{dx}=\frac{2(\sin^2 x+\cos^2 x)}{(\cos(\frac{\pi}{2}-x)+\cos x)^2}$
$\implies \frac{dy}{dx}=\frac{2}{(2\cos(\frac{\pi}{4})\cos(\frac{\pi}{4}-x))^2}$
$\implies \frac{dy}{dx}=\frac{2}{4\cos^2(\frac{\pi}{4})\cos^2(\frac{\pi}{4}-x)}$
$\implies \frac{dy}{dx}=\frac{2}{4\times\frac{1}{2}\cos^2(\frac{\pi}{4}-x)}$
$\implies \frac{dy}{dx}=\sec^2(\frac{\pi}{4}-x)$
$\implies \frac{dy}{dx}-\sec^2(\frac{\pi}{4}-x)=0$
But i have to prove $\frac{dy}{dx}+\sec^2(\frac{\pi}{4}-x)=0$ 
Attempt 2:
$y=\sqrt{\frac{1-\sin 2x}{1+\sin 2x}}$
$\implies y=\sqrt{\frac{\cos^2 x+\sin^2 x-2\cos x \sin x}{\cos^2 x+\sin^2 x+2\cos x \sin x}}$
$\implies y=\sqrt{\frac{(\cos x -\sin x)^2}{(\cos x+\sin x)^2}}$
$\implies y=\frac{\cos x -\sin x}{\cos x +\sin x}$
$\therefore \frac{dy}{dx}=\frac{(\cos x +\sin x)(-\sin x-\cos x)-(\cos x -\sin x)(-\sin x +\cos x)}{(\cos x +\sin x)^2}$ 
$\implies \frac{dy}{dx}=\frac{-(\cos x+\sin x)^2+(\cos x -\sin x)^2}{(\cos x+\sin x)^2}$
$\implies \frac{dy}{dx}=\frac{(\cos x -\sin x)^2-(\cos x+\sin x)^2}{(\cos x+\sin x)^2}$
$\implies \frac{dy}{dx}=\frac{-4\sin x\cos x}{(\cos x+\cos(\frac{\pi}{2}-x))^2}$
$\implies \frac{dy}{dx}=\frac{-4\sin x\cos x}{(2\cos(\frac{\pi}{4})\cos(x-\frac{\pi}{4}))^2}$
$\implies \frac{dy}{dx}=\frac{-4\sin x\cos x}{4\cos^2(\frac{\pi}{4})\cos^2(x-\frac{\pi}{4})}$
$\implies \frac{dy}{dx}=\frac{-4\sin x\cos x}{4\times \frac{1}{2}\cos^2(x-\frac{\pi}{4})}$
$\implies \frac{dy}{dx}=\frac{-2\sin x\cos x}{\cos^2(x-\frac{\pi}{4})}$
Attempt 3:
$y=\sqrt{\frac{1-\sin 2x}{1+\sin 2x}}$
$\implies y=\sqrt{\frac{(1-\sin 2x)(1-\sin 2x)}{(1+\sin 2x)(1-\sin 2x)}}$
$\implies y=\frac{1-\sin 2x}{\cos 2x}$
$\therefore \frac{dy}{dx}=\frac{\cos 2x(-2\cos 2x)-(1-\sin 2x)(-2\sin 2x)}{\cos^2 2x}$
$\implies \frac{dy}{dx}=\frac{-2\cos^2 2x+2\sin 2x(1-\sin 2x)}{\cos^2 2x}$
My questions:
(i) Why does Attempt 2 give a result different from that given by Attempt 1. 
(ii) How do i prove the result?
 A: The statement that you are trying to prove is not true for every $x$. If it was, we would always have $\frac{\mathrm dy}{\mathrm dx}\leqslant0$ and therefore $y$ would be decreasing. But it is increasing in $\left[\frac\pi4,\frac\pi2\right]$, for instance.
The statement holds in $\left(-\frac\pi4,\frac\pi4\right]$. Yours first attempt proves it, as long as you correct this mistake: what you deduce from the equality$$y=\sqrt{\frac{(\sin x-\cos x)^2}{(\sin x+\cos x)^2}}$$is that$$y=\frac{-\sin x+\cos x}{\sin x+\cos x},$$since $y$ is a square root and therefore $y\geqslant0$.
A: "Why does Attempt 2 give a result different from that given by Attempt 1."
Your mistake is that You conclude $\sqrt{a^2}=a$. Actually, one time You conclude that $\sqrt{a^2}=a$ and another time that $\sqrt{(-a)^2}=-a$ although $\sqrt{a^2}$ and $\sqrt{(-a)^2}$ are the same. Correct would be $\sqrt{a^2}=\pm a$, so two values. 
"(ii) How do i prove the result?"
You don't need to do any transformation of the kind, You can directy differentiate the given expression. 
A: In fact, the result you want is not true: it depends on the values of $x$.
Having said this, with a small modification, any of your methods should work.  I'll use your third method.  Note that you have
$$y=\sqrt{\frac{(1-\sin2x)^2}{\cos^22x}}\ ;$$
this gives
$$y=\left|\frac{1-\sin2x}{\cos2x}\right|\ ,$$
and the omission of the absolute values is your main problem.
First, suppose that $-\pi/4<x<\pi/4$.  Then $1-\sin2x>0$ and $\cos2x>0$; so
$$y=\frac{1-\sin2x}{\cos2x}\ .$$
Your differentiation is correct, and you can continue
$$\eqalign{\frac{dy}{dx}
  &=\frac{-2\cos^2 2x+2\sin 2x(1-\sin 2x)}{\cos^2 2x}\cr
  &=\frac{2\sin2x-2}{\cos^22x}\cr
  &=-2\,\frac{1-\sin2x}{1-\sin^22x}\cr
  &=-\frac2{1+\sin2x}\cr
  &=-\frac2{1+\cos(\frac\pi2-2x)}\cr
  &=-\frac1{\cos^2(\frac\pi4-x)}\cr
  &=-\sec^2\Bigl(\frac\pi4-x\Bigr)\cr}$$
which is what you want.
If, however $\pi/4<x<3\pi/4$, then $1-\sin2x>0$ and $\cos2x<0$; so
$$y=-\frac{1-\sin2x}{\cos2x}$$
and exactly the same working will give
$$\frac{dy}{dx}=\sec^2\Bigl(\frac\pi4-x\Bigr)\ .$$
