I let

f(x)=cos(x)

and calculate the (2,4) Padé approximation of f:

(-244/3x^2 - 1/1512000x + 200)/(x^4 - 1/18144000x^3 + 56/3x^2 - 1/1512000*x + 200)

which seems incorrect. (The Taylor series of this rational function has a x^3 term which differs from that of f.)

Am I doing something wrong, or is there a problem with sage?

edit retag close merge delete

Sort by » oldest newest most voted Here is what I get with sage 8.7.beta2. This seems to be correct. Which version of sage are you using ?

sage: x = QQ[['x']].0
sage: f = x.cos()
(-244/3*x^2 + 200)/(x^4 + 56/3*x^2 + 200)
1 - 1/2*x^2 + 1/24*x^4 - 1/720*x^6 - 17/216000*x^8 + 463/32400000*x^10 - 9139/9720000000*x^12 + 23771/1458000000000*x^14 + 1390687/437400000000000*x^16 - 24818093/65610000000000000*x^18 + O(x^20)
sage: f
1 - 1/2*x^2 + 1/24*x^4 - 1/720*x^6 + 1/40320*x^8 - 1/3628800*x^10 + 1/479001600*x^12 - 1/87178291200*x^14 + 1/20922789888000*x^16 - 1/6402373705728000*x^18 + O(x^20)

more

Merci! I am running version 6.6, which gives error messages already for your "f = x.cos()".

However, the answer which you get is not correct either. By definition the (2,4) Pade approximation is a rational function p/q where p is of degree at most 2 and q of degree at most 4.

So the newer version seems to work, I should get a newer one.

Well...

sage: S=cos(x).taylor(x,0,10).power_series(QQ).pade(2,4);S
(-244/3*x^2 + 200)/(x^4 + 56/3*x^2 + 200)
-4*(61*x^2 - 150)/(3*x^4 + 56*x^2 + 600)
sage: bool(M==S)
True


By the way, the Padé approximation is slightly less precise than the Taylor development of the equivalent degree:

sage: S(x=pi).n()
-1.25140289236071
sage: cos(x).taylor(x,0,6)(x=pi).n()
-1.21135284298250


And FredericC's solution is equivalent:

sage: t=QQ[['t']].0
(-244/3*t^2 + 200)/(t^4 + 56/3*t^2 + 200)
sage: bool(T(x)==S)
True


Your Sage version (which is antique, by Sage standards...) gives you bullshit.

more