Simplify fraction within a fraction (Precalculus) Simplify $$\frac{x-2}{x-2-\frac{x}{x-\frac{x-1}{x-2}}}$$
My attempt:
$$=\frac{x-2}{x-2-\frac{x}{\frac{x(x-2)-(x-1)}{x-2}}} \ \ = \  \ \frac{x-2}{x-2-\frac{x}{\frac{x^2-2x-x+1}{x-2}}} \ \ = \ \ \frac{x-2}{x-2-\frac{x^2-2x}{x^2-3x+1}}$$
$$ =\frac{x-2}{\frac{(x-2)(x^2-3x+1)-(x^2-2x)}{x^2-3x+1}} \ \ = \  \ \frac{x-2}{\frac{x^3-3x^2+x-2x^2+6x-2-x^2+2x}{x^2-3x+1}} $$
$$ =\frac{(x-2)(x^2-3x+1)}{x^3-6x^2+9x-2} \ \ = \ \ \frac{x^3-3x^2+x-2x^2+6x-2}{x^3-6x^2+9x-2} $$
$$ =\frac{x^3-5x^2+7x-2}{x^3-6x^2+9x-2} $$
But the answer is given as $ \ \frac{x^2-3x+1}{x^2-4x+1} \ $, so I went wrong somewhere but can't see it. Any help is appreciated thanks.
 A: In the comments I explain how your answer is fine, just not simplified yet.
The way I would have simplifed this though avoids that issue. And you may like to study this technique.
$$\begin{align}
\frac{x-2}{x-2-\frac{x}{x-\frac{x-1}{x-2}}}
&=\frac{x-2}{x-2-\frac{x}{x-\frac{x-1}{x-2}}\cdot\frac{x-2}{x-2}}\\
&=\frac{x-2}{x-2-\frac{x(x-2)}{x(x-2)-(x-1)}}\\
&=\frac{x-2}{x-2-\frac{x(x-2)}{x^2-3x+1}}\cdot\frac{x^2-3x+1}{x^2-3x+1}\\
&=\frac{(x-2)\left(x^2-3x+1\right)}{(x-2)\left(x^2-3x+1\right)-x(x-2)}
\end{align}$$
All those $(x-2)$ cancel now, before you would expend effort multiplying out.
$$\frac{x^2-3x+1}{x^2-3x+1-x}$$
A: Your answer is correct.... Sort of!
The answer you arrived at, can be simplified further to arrive at the answer you wish to achieve, since your attempt is completely valid. So, we have:
$$\frac{x^3-5x^2+7x-2}{x^3-6x^2+9x-2}$$
$$\frac{x^3-5x^2+7x-8+6}{x^3-6x^2+9x-8+6}$$
$$\frac{(x^3-8)-(5x^2-7x-6)}{(x^3-8)-(6x^2-9x-6)}$$
$$\frac{(x-2)(x^2+2x+4)-(5x^2-10x+3x-6)}{(x-2)(x^2+2x+4)-(6x^2-12x+3x-6)}$$
$$\frac{(x-2)(x^2+2x+4)-[5x(x-2)+3(x-2)]}{(x-2)(x^2+2x+4)-[6x(x-2)+3(x-2)]}$$
Factoring out $(x-2)$ from the numerator and denominator and canceling them out, we get:
$$\frac{x^2+2x+4-5x-3}{x^2+2x+4-6x-3}$$
$$\frac{x^2-3x+1}{x^2-4x+1}$$
And that's the desired answer.
A: Less painful:
$$\begin{align}
\frac{x-2}{x-2-\frac{x}{x-\frac{x-1}{x-2}}}&=
\frac{x-2}{x-2-\frac{x(x-2)}{x(x-2)-x+1}}\\
&=\frac{(x-2)\bigl(x(x-2)-x+1\bigr)}{(x-2)\bigl(x(x-2)-x+1\bigr)-x(x-2)}.
\end{align}
$$
Now cancel by $x-2$ and multiply out to get
$$\frac{x^2-3x+1}{x^2-4x+1}.$$
