ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 03 Dec 2017 09:00:33 -0600can series make mistakes?http://ask.sagemath.org/question/39909/can-series-make-mistakes/ series seems to make errors . luckily, taylor works correctly.
start with L_F=(exp(-s)-1+s)/(s^2/2) (laplace transform of the "equilibrium" uniform density)
and switch to Pollaczek laplace transform L_F /(1- epsilon * L_F);
You can check that the moments expansions t, t1 differ
var('s');n=2
L_F=(exp(-s)-1+s)/(s^2/2) #satisfies L_F(s=0)=1
L_L=L_F/(1-L_F/3)
t = L_L.series(s,2*n+2)
t1= taylor(L_L,s,0,2*n+2)
print t1Sat, 02 Dec 2017 04:16:35 -0600http://ask.sagemath.org/question/39909/can-series-make-mistakes/Comment by vdelecroix for <p>series seems to make errors . luckily, taylor works correctly.
start with L_F=(exp(-s)-1+s)/(s^2/2) (laplace transform of the "equilibrium" uniform density)
and switch to Pollaczek laplace transform L_F /(1- epsilon * L_F); <br>
You can check that the moments expansions t, t1 differ</p>
<p>var('s');n=2
L_F=(exp(-s)-1+s)/(s^2/2) #satisfies L_F(s=0)=1
L_L=L_F/(1-L_F/3)
t = L_L.series(s,2<em>n+2)
t1= taylor(L_L,s,0,2</em>n+2)
print t1</p>
http://ask.sagemath.org/question/39909/can-series-make-mistakes/?comment=39910#post-id-39910Please format your code! If you make indentation by four spaces, you got nicely printed code like
x = 3
print(x)Sat, 02 Dec 2017 05:29:12 -0600http://ask.sagemath.org/question/39909/can-series-make-mistakes/?comment=39910#post-id-39910Answer by eric_g for <p>series seems to make errors . luckily, taylor works correctly.
start with L_F=(exp(-s)-1+s)/(s^2/2) (laplace transform of the "equilibrium" uniform density)
and switch to Pollaczek laplace transform L_F /(1- epsilon * L_F); <br>
You can check that the moments expansions t, t1 differ</p>
<p>var('s');n=2
L_F=(exp(-s)-1+s)/(s^2/2) #satisfies L_F(s=0)=1
L_L=L_F/(1-L_F/3)
t = L_L.series(s,2<em>n+2)
t1= taylor(L_L,s,0,2</em>n+2)
print t1</p>
http://ask.sagemath.org/question/39909/can-series-make-mistakes/?answer=39925#post-id-39925The output of `L_L.series(s, 2*n+2)` is erroneous because of the division by `s^2`, which causes some trouble at `s=0`. You have to simplify the expression of `L_L`, via `simplify_full()`, prior to the call to `series`. Then you will get a correct result:
sage: L_L = L_L.simplify_full()
sage: L_L.series(s, 2*n+2)
3/2 + (-3/4)*s + 5/16*s^2 + (-29/240)*s^3 + 263/5760*s^4 + (-4157/241920)*s^5 + Order(s^6)
sage: taylor(L_L, s, 0, 2*n+2)
93881/14515200*s^6 - 4157/241920*s^5 + 263/5760*s^4 - 29/240*s^3 + 5/16*s^2 - 3/4*s + 3/2
On general grounds, it is usually preferable to simplify an expression before manipulating it.Sun, 03 Dec 2017 09:00:33 -0600http://ask.sagemath.org/question/39909/can-series-make-mistakes/?answer=39925#post-id-39925