Continued Fractions Approximation I have come across continued fractions approximation but I am unsure what the steps are. 
For example How would you express the following rational function in continued-fraction form:
$${x^2+3x+2 \over x^2-x+1}$$
 A: This might be what you are looking for:
$$
\begin{align}
\frac{x^2+3x+2}{x^2-x+1}
&=1+\cfrac{4x+1}{x^2-x+1}\\[4pt]
&=1+\cfrac1{\frac14x-\frac5{16}+\cfrac{\frac{21}{16}}{4x+1}}\\[4pt]
&=1+\cfrac1{\frac14x-\frac5{16}+\cfrac1{\frac{64}{21}x+\frac{16}{21}}}
\end{align}
$$
At each stage, we are doing a polynomial division instead of an integer division, but otherwise, the process is the same as with continued fractions with integers.
We can get the Bezout polynomials by truncating the continued fraction:
$$
1+\cfrac1{\frac14x-\frac5{16}}=\frac{4x+11}{4x-5}
$$
That is, we can write the polynomial GCD (a constant since they are relatively prime) as
$$
(4x+11)(x^2-x+1)-(4x-5)(x^2+3x+2)=21
$$
A: Start out writing
$$\frac{x^2+3x+2}{x^2-x+1}=\frac{1}{\frac{(x^2+3x+2)-(4x+1)}{x^2+3x+2}}=\frac{1}{1-\frac{4x+1}{x^2+3x+2}}$$
and then iterate doing the same with the fraction in the denominator.
EDIT: Complete solution:
By polynomial long division we have $\frac{x^2+3x+2}{4x+1}=\frac{x}{4}+\frac{11}{16}+\frac{21}{16}\frac{1}{4x+1}$. Hence the above expression equals
$$\huge
\frac{1}{1-\frac{1}{x/4+11/16+\frac{1}{40x/21+10/21}}}.
$$
