<s>[INST] Pade approximant for the function $\sqrt{1+x}$ I'm doing the followiwng exercise:

The objective is to obtain an approximation for the square root of any given number using the expression
$$\sqrt{1+x}=f(x)\cdot\sqrt{1+g(x)}$$
where g(x) is an infinitesimal. If we choose $f(x)$ as an approximation of $\sqrt{1+x}$, then we can calculate $g(x)$:
$$g(x)=\frac{1+x}{f^2(x)}-1$$
$f(x)$ can be chosen as a rational function $p(x)/q(x)$, such that $p$ and $q$ have the same degree and it's Mclaurin series is equal to the Mclaurin series of the function $\sqrt{1+x}$ until some degree. Find a rational function $f(x):=p(x)/q(x)$, quotient of two linear polynomials, such that the McLaurin series of $p(x)-\sqrt{1+x}\cdot q(x)$ have the three first terms equal to $0$.

How can I do this? Has something to be with the Pade approximant?
Any hint would be really appreciated. Thanks for your time.
 [/INST] Using the fact that $\sqrt{1+x}=1+\frac x{1+\sqrt{1+x}}$, we get
$$
\begin{align}
\sqrt{1+x}
&=1+\cfrac x{2+\cfrac x{2+\cfrac x{2+\cfrac x{2+\cdots}}}}
\end{align}
$$
Which gives the approximants
$$
\begin{align}
\color{#C00000}{1+\frac12x}&=1+\frac12x\\
\color{#00A000}{\frac{1+\frac34x}{1+\frac14x}}&=1+\frac12x-\frac18x^2+\frac1{32}x^3-\frac1{128}x^4+O\left(x^5\right)\\
\color{#5555FF}{\frac{1+x+\frac18x^2}{1+\frac12x}}&=1+\frac12x-\frac18x^2+\frac1{16}x^3-\frac1{32}x^4+O\left(x^5\right)\\
\color{#C0A000}{\frac{1+\frac54x+\frac5{16}x^2}{1+\frac34x+\frac1{16}x^2}}&=1+\frac12x-\frac18x^2+\frac1{16}x^3-\frac5{128}x^4+O\left(x^5\right)\\
\sqrt{1+x}&=1+\frac12x-\frac18x^2+\frac1{16}x^3-\frac5{128}x^4+O\left(x^5\right)
\end{align}
$$

</s>