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.Sat, 02 Jun 2012 07:21:06 -0500Working with serieshttp://ask.sagemath.org/question/9004/working-with-series/I can't get how to work with series. I do
sage: R.<t> = PowerSeriesRing(QQ)
sage: t^2
t^2
sage: sin(t)
but the last rises an error. I want to do usual manipulations like `sin(t)/cos(t+2)^2`.
Fri, 01 Jun 2012 09:07:02 -0500http://ask.sagemath.org/question/9004/working-with-series/Comment by yrogirg for <p>I can't get how to work with series. I do</p>
<pre><code>sage: R.<t> = PowerSeriesRing(QQ)
sage: t^2
t^2
sage: sin(t)
</code></pre>
<p>but the last rises an error. I want to do usual manipulations like <code>sin(t)/cos(t+2)^2</code>.</p>
http://ask.sagemath.org/question/9004/working-with-series/?comment=19704#post-id-19704yes, generally Puiseux series would be better, but sin t is to return Taylor expansion around zero if it doesn't specified in it's type directly.Fri, 01 Jun 2012 19:07:22 -0500http://ask.sagemath.org/question/9004/working-with-series/?comment=19704#post-id-19704Comment by niles for <p>I can't get how to work with series. I do</p>
<pre><code>sage: R.<t> = PowerSeriesRing(QQ)
sage: t^2
t^2
sage: sin(t)
</code></pre>
<p>but the last rises an error. I want to do usual manipulations like <code>sin(t)/cos(t+2)^2</code>.</p>
http://ask.sagemath.org/question/9004/working-with-series/?comment=19708#post-id-19708What do you mean by sin(t)? Do you want the Taylor series for sin around some point?Fri, 01 Jun 2012 14:05:23 -0500http://ask.sagemath.org/question/9004/working-with-series/?comment=19708#post-id-19708Answer by niles for <p>I can't get how to work with series. I do</p>
<pre><code>sage: R.<t> = PowerSeriesRing(QQ)
sage: t^2
t^2
sage: sin(t)
</code></pre>
<p>but the last rises an error. I want to do usual manipulations like <code>sin(t)/cos(t+2)^2</code>.</p>
http://ask.sagemath.org/question/9004/working-with-series/?answer=13644#post-id-13644Use the [`taylor`](http://www.sagemath.org/doc/constructions/calculus.html#power-series) method to get a Taylor polynomial. This needs to be done in the symbolic ring since the power series ring is purely algebraic and doesn't know about derivatives.
sage: t = var('t')
sage: f = sin(t)
sage: s_poly = f.taylor(t,0,7)
sage: s_poly
-1/5040*t^7 + 1/120*t^5 - 1/6*t^3 + t
sage: s_poly.parent()
Symbolic Ring
The `power_series` method will convert the Taylor polynomial to a power series for you:
sage: s_ser = s_poly.power_series(QQ)
sage: s_ser
t - 1/6*t^3 + 1/120*t^5 - 1/5040*t^7 + O(t^8)
sage: s_ser.parent()
Power Series Ring in t over Rational Field
sage: g = cos(t)
sage: c_poly = g.taylor(t,0,7)
sage: c_poly
-1/720*t^6 + 1/24*t^4 - 1/2*t^2 + 1
sage: c_ser = c_poly.power_series(QQ)
sage: c_ser
1 - 1/2*t^2 + 1/24*t^4 - 1/720*t^6 + O(t^7)
Over the power series ring, you can do arithmetic with the power series. Note that you will need to change "`t`" from the generator of the symbolic ring to the generator of the power series ring in order to use things like `t+2`:
sage: t.parent()
Symbolic Ring
sage: t = s_ser.parent().gen()
sage: t.parent()
Power Series Ring in t over Rational Field
sage: s_ser/c_ser(t+2)
-45/19*t + 1890/361*t^2 - 83085/6859*t^3 + 3677670/130321*t^4 - 649441779/9904396*t^5 + 7173329982/47045881*t^6 - 17745663554041/50056817384*t^7 + O(t^8)
Sat, 02 Jun 2012 07:21:06 -0500http://ask.sagemath.org/question/9004/working-with-series/?answer=13644#post-id-13644