ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 02 Dec 2017 03:08:41 -0600using pade approxhttps://ask.sagemath.org/question/39870/using-pade-approx/ Hi 1) From the only example I found
s = PowerSeriesRing(QQ,'s').gen()
a=exp(s);a.pade(4, 0)
type(a)
it seems this works for type 'sage.rings.power_series_poly.PowerSeries_poly'
But I have a type 'sage.symbolic.expression.Expression' b,
and was unable to convert b to the type required to apply pade
2) There's an alternative rational.reconstruct , but that seems to be geared to computations modulo (n)
3) In conclusion, it seems at current stage the simplest is to write one's own Pade? Thanks, Florin
Fri, 01 Dec 2017 04:13:14 -0600https://ask.sagemath.org/question/39870/using-pade-approx/Comment by dan_fulea for <p>Hi 1) From the only example I found
s = PowerSeriesRing(QQ,'s').gen()
a=exp(s);a.pade(4, 0)
type(a)</p>
<p>it seems this works for type 'sage.rings.power_series_poly.PowerSeries_poly'</p>
<p>But I have a type 'sage.symbolic.expression.Expression' b,
and was unable to convert b to the type required to apply pade</p>
<p>2) There's an alternative rational.reconstruct , but that seems to be geared to computations modulo (n)
3) In conclusion, it seems at current stage the simplest is to write one's own Pade? Thanks, Florin</p>
https://ask.sagemath.org/question/39870/using-pade-approx/?comment=39901#post-id-39901- Please give us a, or the `b` from (1), so that potential helpers have a clear idea what kind of expressions are involved, and give the solution working in that particular case in any case.
- There is a function `rational_reconstruction`, indeed. But i do not see it as an alternative, it is designed only for the special use described in its doc string, offered e.g. by typing `rational_reconstruction?` in the sage interpreter.
- No, i would say, simplest for me is to use the `pade` method inside the class where it is genuinely defined. So just start with a `b` which is some function in `s` - say, convert is somehow to a power series, get the result, and possibly come back. But why do we need such a complication, why is the input `b` not directly in the `PowerSeriesRing` of `QQ` ?!Fri, 01 Dec 2017 14:51:57 -0600https://ask.sagemath.org/question/39870/using-pade-approx/?comment=39901#post-id-39901Answer by FrédéricC for <p>Hi 1) From the only example I found
s = PowerSeriesRing(QQ,'s').gen()
a=exp(s);a.pade(4, 0)
type(a)</p>
<p>it seems this works for type 'sage.rings.power_series_poly.PowerSeries_poly'</p>
<p>But I have a type 'sage.symbolic.expression.Expression' b,
and was unable to convert b to the type required to apply pade</p>
<p>2) There's an alternative rational.reconstruct , but that seems to be geared to computations modulo (n)
3) In conclusion, it seems at current stage the simplest is to write one's own Pade? Thanks, Florin</p>
https://ask.sagemath.org/question/39870/using-pade-approx/?answer=39900#post-id-39900You need to convert your symbolic expression to a symbolic Taylor series, then to a formal power series.
Typical example:
sage: f=sin(x)+cos(x)
sage: g=f.series(x,28)
sage: h=QQ[['x']](g)
sage: h.pade(4,4)
(127441/6601*x^4 - 481140/6601*x^3 - 2632500/6601*x^2 + 709560/943*x + 749040/943)/(x^4 - 10940/6601*x^3 + 265500/6601*x^2 - 39480/943*x + 749040/943)
Fri, 01 Dec 2017 14:46:54 -0600https://ask.sagemath.org/question/39870/using-pade-approx/?answer=39900#post-id-39900Comment by florin for <p>You need to convert your symbolic expression to a symbolic Taylor series, then to a formal power series.</p>
<p>Typical example:</p>
<pre><code>sage: f=sin(x)+cos(x)
sage: g=f.series(x,28)
sage: h=QQ[['x']](g)
sage: h.pade(4,4)
(127441/6601*x^4 - 481140/6601*x^3 - 2632500/6601*x^2 + 709560/943*x + 749040/943)/(x^4 - 10940/6601*x^3 + 265500/6601*x^2 - 39480/943*x + 749040/943)
</code></pre>
https://ask.sagemath.org/question/39870/using-pade-approx/?comment=39908#post-id-39908it works now! Thanks both of you and excuses for my silly novice questions.
Both series and taylor which I had tried before work fine (I guess both must have advantages sometimes
if they are kept ?)
adding the QQ magic changed the donna
Here's the example
var('s')
L_F=(exp(-s)-1+s)/(s^2)
t=L_F.series(s,6) #t = taylor(L_F,s,0,6)
h=QQ[['s']](t)
h.pade(2,2)
Sat, 02 Dec 2017 03:08:41 -0600https://ask.sagemath.org/question/39870/using-pade-approx/?comment=39908#post-id-39908