Ask Your Question
1

Problem with Padé approximation

asked 2019-02-04 14:07:16 +0100

Tomas Persson gravatar image

I let

f(x)=cos(x)

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

f.taylor(x,0,10).power_series(QQ).pade(2,4)

Sage answers with

(-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 flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2019-02-04 20:01:46 +0100

FrédéricC gravatar image

updated 2019-02-04 20:02:04 +0100

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()
sage: f.pade(2,4)
(-244/3*x^2 + 200)/(x^4 + 56/3*x^2 + 200)
sage: f.pade(2,4)(x)
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)
edit flag offensive delete link more

Comments

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.

Tomas Persson gravatar imageTomas Persson ( 2019-02-04 21:01:06 +0100 )edit

Sorry! I read too fast, and misunderstood "f.pade(2,4)(x)" as the Pade approximation!

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

Tomas Persson gravatar imageTomas Persson ( 2019-02-04 21:04:03 +0100 )edit
2

answered 2019-02-05 11:00:34 +0100

Emmanuel Charpentier gravatar image

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)
sage: M=mathematica.PadeApproximant(cos(x),[x,0,[2,4]]).sage();M
-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
sage: T=t.cos().pade(2,4);T
(-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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-02-04 14:07:16 +0100

Seen: 802 times

Last updated: Feb 05 '19