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.Mon, 18 Mar 2019 16:02:40 -0500A problem in powerserieshttp://ask.sagemath.org/question/45792/a-problem-in-powerseries/It seems there is a problem when expanding tan(t), sinh(t), cosh(t) using PowerSeries. The following works fine
R.<t> = PowerSeriesRing(QQ)
sin(t)/cos(t)
t + 1/3*t^3 + 2/15*t^5 + 17/315*t^7 + 62/2835*t^9 + 1382/155925*t^11 + 21844/6081075*t^13 + 929569/638512875*t^15 + 6404582/10854718875*t^17 + 443861162/1856156927625*t^19 + O(t^20)
However, `tan(t)` returns
TypeError: cannot coerce arguments: no canonical coercion from Power Series Ring in t over Rational Field to Symbolic RingSat, 16 Mar 2019 10:41:49 -0500http://ask.sagemath.org/question/45792/a-problem-in-powerseries/Comment by irizos for <p>It seems there is a problem when expanding tan(t), sinh(t), cosh(t) using PowerSeries. The following works fine</p>
<pre><code>R.<t> = PowerSeriesRing(QQ)
sin(t)/cos(t)
t + 1/3*t^3 + 2/15*t^5 + 17/315*t^7 + 62/2835*t^9 + 1382/155925*t^11 + 21844/6081075*t^13 + 929569/638512875*t^15 + 6404582/10854718875*t^17 + 443861162/1856156927625*t^19 + O(t^20)
</code></pre>
<p>However, <code>tan(t)</code> returns </p>
<pre><code>TypeError: cannot coerce arguments: no canonical coercion from Power Series Ring in t over Rational Field to Symbolic Ring
</code></pre>
http://ask.sagemath.org/question/45792/a-problem-in-powerseries/?comment=45799#post-id-45799Thanks for the replies. Of course talylor can do the job, however I had in mind more compex calculations with several steps where the series expanded results from the first step can be used in the next one and so on. PowerSeries is very usefull to this end. I guess at some point in the future more methods will be included in PowerSeries. Some of them e.g. sinh(x), cosh(x) which can be explicitly written in terms of exponentials would be simple to implement , I guess.Sat, 16 Mar 2019 19:04:30 -0500http://ask.sagemath.org/question/45792/a-problem-in-powerseries/?comment=45799#post-id-45799Comment by vdelecroix for <p>It seems there is a problem when expanding tan(t), sinh(t), cosh(t) using PowerSeries. The following works fine</p>
<pre><code>R.<t> = PowerSeriesRing(QQ)
sin(t)/cos(t)
t + 1/3*t^3 + 2/15*t^5 + 17/315*t^7 + 62/2835*t^9 + 1382/155925*t^11 + 21844/6081075*t^13 + 929569/638512875*t^15 + 6404582/10854718875*t^17 + 443861162/1856156927625*t^19 + O(t^20)
</code></pre>
<p>However, <code>tan(t)</code> returns </p>
<pre><code>TypeError: cannot coerce arguments: no canonical coercion from Power Series Ring in t over Rational Field to Symbolic Ring
</code></pre>
http://ask.sagemath.org/question/45792/a-problem-in-powerseries/?comment=45796#post-id-45796For the situation you presented, you could use `tan(t).taylor(t, 0, 10)`Sat, 16 Mar 2019 14:34:29 -0500http://ask.sagemath.org/question/45792/a-problem-in-powerseries/?comment=45796#post-id-45796Comment by FrédéricC for <p>It seems there is a problem when expanding tan(t), sinh(t), cosh(t) using PowerSeries. The following works fine</p>
<pre><code>R.<t> = PowerSeriesRing(QQ)
sin(t)/cos(t)
t + 1/3*t^3 + 2/15*t^5 + 17/315*t^7 + 62/2835*t^9 + 1382/155925*t^11 + 21844/6081075*t^13 + 929569/638512875*t^15 + 6404582/10854718875*t^17 + 443861162/1856156927625*t^19 + O(t^20)
</code></pre>
<p>However, <code>tan(t)</code> returns </p>
<pre><code>TypeError: cannot coerce arguments: no canonical coercion from Power Series Ring in t over Rational Field to Symbolic Ring
</code></pre>
http://ask.sagemath.org/question/45792/a-problem-in-powerseries/?comment=45795#post-id-45795This is because the power series do have "sin" and "cos" methods, but no "tan" method. So Sage tries to fall back to the symbolic ring SR and fails.Sat, 16 Mar 2019 11:38:51 -0500http://ask.sagemath.org/question/45792/a-problem-in-powerseries/?comment=45795#post-id-45795Answer by Emmanuel Charpentier for <p>It seems there is a problem when expanding tan(t), sinh(t), cosh(t) using PowerSeries. The following works fine</p>
<pre><code>R.<t> = PowerSeriesRing(QQ)
sin(t)/cos(t)
t + 1/3*t^3 + 2/15*t^5 + 17/315*t^7 + 62/2835*t^9 + 1382/155925*t^11 + 21844/6081075*t^13 + 929569/638512875*t^15 + 6404582/10854718875*t^17 + 443861162/1856156927625*t^19 + O(t^20)
</code></pre>
<p>However, <code>tan(t)</code> returns </p>
<pre><code>TypeError: cannot coerce arguments: no canonical coercion from Power Series Ring in t over Rational Field to Symbolic Ring
</code></pre>
http://ask.sagemath.org/question/45792/a-problem-in-powerseries/?answer=45828#post-id-45828If working in SR is good enough for your problem :
tan(x).maxima_methods().powerseries(x,0)
sum((2^(2*i1) - 1)*2^(2*i1)*(-1)^(i1 - 1)*x^(2*i1 - 1)*bern(2*i1)/factorial(2*i1), i1, 0, +Infinity)
HTH,
Mon, 18 Mar 2019 16:02:40 -0500http://ask.sagemath.org/question/45792/a-problem-in-powerseries/?answer=45828#post-id-45828