Divide the first of those equations by $\cos\theta$ to see that $\tan\theta = \sqrt2-1$. Similarly, the second equation is equivalent to $\tan\theta = \frac1{\sqrt2+1}$. Now complete the argument by showing that $\sqrt2-1 = \frac1{\sqrt2+1}$,