How to use the pade function to calculate the pade approximation of a function. I have a function (for example arctan(x) ) and would like to calculate the pade approximation of that function. I have found that there exists a function for that in sage, but I was not able to run it, could someone help me with that?

edit retag close merge delete

Sort by » oldest newest most voted

Let f be your function, here a symbolic expression:

sage: f = arctan(x)
sage: f.parent()
Symbolic Ring


If you search for "pade sagemath" you will get this page http://doc.sagemath.org/html/en/refer... so you have first to transform the symbolic expression arctan(x) into a power series. As you can see, the symbolic expression has a method named power_series, so let us try it:

sage: f.power_series(QQ)
TypeError: unable to convert arctan(x) to a rational


The problem is that, currently, Sage is not able to transform such a symbolic expression into a power series, only the expressions that are polynomials, see the doc of the method by typing f.power_series

So, you have first to approximate f to a truncated power series, also known as Taylor expansion:

sage: f.taylor(x,0,12)
-1/11*x^11 + 1/9*x^9 - 1/7*x^7 + 1/5*x^5 - 1/3*x^3 + x


Then you can get it as a power series over the rationals:

sage: f.taylor(x,0,12).power_series(QQ)
x - 1/3*x^3 + 1/5*x^5 - 1/7*x^7 + 1/9*x^9 - 1/11*x^11 + O(x^12)


sage: f.taylor(x,0,12).power_series(QQ).pade(3,3)
(4/9*x^3 + 5/3*x)/(x^2 + 5/3)


Of course, the higher pade approximant you require, the higer the degree in the Taylor expansion:

sage: f.taylor(x,0,12).power_series(QQ).pade(10,10)
ValueError: the precision of the series is not large enough

(61567/3969*x^9 + 106964/441*x^7 + 44902/45*x^5 + 281996/189*x^3 + 46189/63*x)/(x^10 + 55*x^8 + 1430/3*x^6 + 1430*x^4 + 12155/7*x^2 + 46189/63)

more

Hi, is it possible to go back to a power series? If I give

sage: f.taylor(x,0,12).power_series(QQ).pade(3,3).taylor(x,0,12)


I get the error: AttributeError: 'FractionFieldElement_1poly_field' object has no attribute 'taylor'

( 2017-08-29 06:40:52 -0500 )edit