<s>[INST] 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.
 [/INST] 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}$$
</s>