TITLE: How to approximate $\sin(x)$ using Padé approximation?
QUESTION [7 upvotes]: I need to write a function for $\sin(x)$ using Padé approximation.
I found here a formula, but I don't know how to achive this.

Thanks in advance.

REPLY [6 votes]: The relation $p_k/q_k=\sin(x)+O(x^N)$ or $p_k=s_N·q_k+O(x^N)$ can be interpreted as one stage in the extended euclidean algorithm starting with $r_0=x^N$, $r_1=s_n$ and propagating the Bezout identities $r_k=u_ks_N+v_kx^N$, $u_0=0, u_1=1$, $v_0=1, v_1=1$ and identifying $p_k=r_k$, $q_k=u_k$. Implementing in Magma CAS which you can try out with the online calculator
PS<z>:=PowerSeriesRing(Rationals());
P<x>:=PolynomialRing(Rationals());
PadeSin:=function(N)
    sN := Truncate(Sin(z+O(z^N)));
    sN := Evaluate(sN,x);
    r0 := x^N; u0:=0;
    r1 := sN;  u1:=1;
    for k in [2..N] do
        if Degree(r1) lt 2 then break; end if;
        q1,r2 := Quotrem(r0,r1); // r2 = r0-q1*r1
        u2 := u0-q1*u1;
        a := Coefficient(u2,0);
        printf "k=%o : p/q = (%o)/(%o)\n",k,r2/a,u2/a;
        r0:=r1; r1:=r2;
        u0:=u1; u1:=u2;
    end for;
    return r1,u1;
end function;

for N in [5,7,13] do "\norder N=", N; PadeSin(N); end for;

gives a result of 
order N= 5
k=2 : p/q = (x)/(1/6*x^2 + 1)

order N= 7
k=2 : p/q = (-7/60*x^3 + x)/(1/20*x^2 + 1)
k=3 : p/q = (x)/(7/360*x^4 + 1/6*x^2 + 1)

order N= 13
k=2 : p/q = (19/19958400*x^9 - 17/138600*x^7 + 3/440*x^5 - 26/165*x^3 + x)/(1/110*x^2 + 1)
k=3 : p/q = (-121/2268000*x^7 + 601/118800*x^5 - 241/1650*x^3 + x)/(19/118800*x^4 + 17/825*x^2 + 1)
k=4 : p/q = (12671/4363920*x^5 - 2363/18183*x^3 + x)/(121/16662240*x^6 + 601/872784*x^4 + 445/12122*x^2 + 1)
k=5 : p/q = (-2555/25146*x^3 + x)/(12671/7604150400*x^8 + 2363/31683960*x^6 + 3787/1508760*x^4 + 818/12573*x^2 + 1)
k=6 : p/q = (x)/(73/3421440*x^10 + 127/604800*x^8 + 31/15120*x^6 + 7/360*x^4 + 1/6*x^2 + 1)

where you find under N=13, k=5 your cited fraction.