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.
 A: 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}
$$

A: Using the idea of continued fractions, observe that
$$
\sqrt{1+x}=1+(\sqrt{1+x}-1)=1+\frac{x}{2+(\sqrt{1+x}-1)}\\=1+\cfrac{x}{2+\cfrac{x}{2+(\sqrt{1+x}-1)}}=…
$$
continuing in an obvious repetitive pattern.
The computation of the (degree-balanced) partial fractions of this can be implemented (in Magma CAS) as
F<x>:=RationalFunctionField(Rationals());
p := 0;
for k in [1..6] do
   p := x/(2+x/(2+p));
   print 1+p;
end for;

with the results (for instance using http://magma.maths.usyd.edu.au/calc/)
(3*x + 4)/(x + 4)
(5*x^2 + 20*x + 16)/(x^2 + 12*x + 16)
(7*x^3 + 56*x^2 + 112*x + 64)/(x^3 + 24*x^2 + 80*x + 64)
(9*x^4 + 120*x^3 + 432*x^2 + 576*x + 256)/(x^4 + 40*x^3 + 240*x^2 + 448*x + 256)
(11*x^5 + 220*x^4 + 1232*x^3 + 2816*x^2 + 2816*x + 1024)/(x^5 + 60*x^4 + 560*x^3 + 1792*x^2 + 2304*x + 1024)
(13*x^6 + 364*x^5 + 2912*x^4 + 9984*x^3 + 16640*x^2 + 13312*x + 4096)/(x^6 + 84*x^5 + 1120*x^4 + 5376*x^3 + 11520*x^2 + 11264*x + 4096)

as the first six balanced Pade approximants.
A: Since apparently no condition is made that the order of approximation should be maximal for the degree, you do not need to employ Pade approximants. So you can just simply set
$$
1+x=\frac{1+y}{1-y}\iff  y=\frac{x}{2+x}
$$
and use Taylor polynomials of equal degree for $\sqrt{1\pm y}$.

In first order, you would get $\sqrt{1\pm y}\approx 1\pm\frac12y$ and
$$
\frac{2+y}{2-y}=\frac{4+2x+x}{4+2x-x}=\frac{4+3x}{4+x}.
$$

Second order has $\sqrt{1\pm y}\approx 1\pm\frac12y-\frac18y^2$ which leads to
$$
\frac{8+4y-y^2}{8-4y-y^2}=\frac{32+32x+8x^2+(8x+4x^2)-x^2}{32+32x+8x^2-(8x+4x^2)-x^2}=\frac{32+40x+11x^2}{32+24x+3x^2}
$$
A: You can work this out without MacLaurin, starting from
$$p^2(x)\approx(1+x)q^2(x).$$
Then with
$$p(x)=(1+ax)^2,q(x)=(1+bx)^2,$$
we have
$$1+2ax+a^2x^2\approx1+(2b+1)x+(b^2+2b)x^2+b^2x^3,$$
and we identify
$$2a=2b+1,\\a^2=b^2+2b$$
which gives the solution
$$\sqrt{1+x}\approx\frac{1+\frac34x}{1+\frac14x}.$$
A: Without referring explicitly to Pade approximants, let's try with the simplest case - i.e. two linear terms i.e. let $p = ax+b, \quad q = cx+d$, then our condition is $g(x) = p(x) - \sqrt{1+x} \cdot q(x) $ should have the first three terms zero.
Setting $g(0) = g'(0) = g''(0)=0$ gives $b = d = \frac43a, \; c = \frac13a$, so we have 
$$\sqrt{1+x} \approx \frac{x+\frac43}{\frac13x+\frac43} = \frac{3x+4}{x+4}$$
satisfying the required condition. 
The graph below of $\color{blue} {\sqrt{1+x}}$ and $\color {red} {p/q}$ should show you how surprisingly accurate (like continued fractions) this gets.

