Simplify a trigonometric expression I've been simplying a slew of trigonometric expressions and most of them fall out pretty clearly, but this one has been giving me fits:
$$\frac{(\sec x - \tan x)^{2} + 1}{\sec x\csc x - \tan x\csc x}$$
Here's my best attempt so far:
$$\begin{align*}
&=\frac{\left(\frac{1}{\cos x}-\frac{\sin x}{\cos x} \right)^{2} + 1}{\frac{1}{\cos x\sin x}-\frac{1}{\cos x}}\\\\
&=\frac{\frac{1}{\cos^{2}x}-2\frac{\sin x}{\cos^{2}x}+\frac{\sin^{2}x}{\cos^{2}x} + 1}{\frac{\cos x-\cos x\sin x}{\cos^{2}x\sin x}}
\end{align*}$$
But I can't help but think I've already gone wrong since I feel like I should start factoring things out again. Am I on the right track here?
Thanks for any suggestions.
 A: I might start by factoring out the $\frac{1}{\csc x}$ (aka $\sin x$) and then multiplying by $\frac{\sec x+\tan x}{\sec x+\tan x}$, since $\sec^2x-\tan^2x =1$. This leaves
$$\sin(x)\left((\sec x-\tan x)^2 + 1\right)\left(\sec x+\tan x\right)$$
Distribute and repeat the identity... 
$$\sin(x)\left(\sec x-\tan x + \sec x+\tan x\right)$$
And then we end up with $2\tan(x)$.
(Subtle note: The original expression was undefined for $x=n\pi$, since it involved $\csc(x)$. So really, this simplifies to $2\tan(x), x\neq n\pi$; its graph is like that of $2\tan(x)$, but with holes at every $x$-intercept.)
A: There are certainly more efficient ways, as Ross and alex have already indicated, but if you want to continue on the path on which you've started, note that 
$$\begin{align*}
&\frac{\frac{1}{\cos^{2}x}-2\frac{\sin x}{\cos^{2}x}+\frac{\sin^{2}x}{\cos^{2}x} + 1}{\frac{\cos x-\cos x\sin x}{\cos^{2}x\sin x}}\cdot\frac{\cos^2x}{\cos^2x}\\\\
&\qquad=\frac{1-2\sin x+\sin^2x+\cos^2x}{\frac{\cos x(1-\sin x)}{\sin x}}\;.
\end{align*}$$
Now use an obvious identity in the numerator, invert the denominator and multiply, and you're home free.
A: We use $\sec^2 x-tan^2 x=1$, and replace the $1$ in the numerator by $\sec^2 x-\tan^2 x$. Then note the common factor $\sec x-\tan x$ appearing everywhere. Cancel it, noting the possible problem of cancelling $0$'s, or don't note it, because for reason unknown to me it is considered OK not to with trig identities.
After we cancel, we have
$$\frac{(\sec x-\tan x)+(\sec x+\tan x)}{\csc x}.$$
Now we are essentially finished. The numerator is $2\sec x$, the denominator is $\csc x$. Replace them by $2/\cos x$ and $1/\sin x$ respectively, and we get $2\tan x$.
A: You have
$$\begin{align*}
&=\frac{(\frac{1}{\cos x}-\frac{\sin x}{\cos x})^{2} + 1}{\frac{1}{\cos x\sin x}-\frac{1}{\cos x}}\\
&=\frac{\frac{1}{\cos^{2}x}-2\frac{\sin x}{\cos^{2}x}+\frac{\sin^{2}x}{\cos^{2}x} + 1}{\frac{\cos x-\cos x\sin x}{\cos^{2}x\sin x}}
\end{align*}$$
Your next steps might be to note that on top, $\sin x/\cos x = \tan x$ and $1 + \tan^2 x= \sec^2 x$, leaving you with $2\dfrac{(1 -  \sin x)}{\cos ^2 x}$ 
On the bottom, you have $\dfrac{\cos x}{\sin x}\dfrac{(1 - \sin x)}{\cos ^2 x}$
So cancel all that you can, and I think you'll be able to finish from here.
