ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 26 Nov 2014 11:32:46 +0100Coefficients in Polynomial Ring over Symbolic Ring ?https://ask.sagemath.org/question/24968/coefficients-in-polynomial-ring-over-symbolic-ring/ Consider
x = SR.var('x')
gf = exp(x)*(bessel_I(0, 2*x)-bessel_I(1, 2*x))
t = gf.series(x, 6).simplify_full()
print t.coefficients()
Q.<x> = PolynomialRing(SR)
Q(t)
The output is:
[[Order(x^6) + 1, 0], [1/2, 2], [1/6, 3], [1/8, 4], [1/20, 5]]
1/20*x^5 + 1/8*x^4 + 1/6*x^3 + 1/2*x^2 + Order(x^6) + 1
'Order(x^6)' is a coefficient of a polynomial?
**Solution** by kcrisman:
x = SR.var('x')
gf = exp(x)*(bessel_I(0, 2*x)-bessel_I(1, 2*x))
t = gf.series(x, 6).truncate().simplify_full()
print t.coefficients()
Q.<x> = PolynomialRing(SR)
Q(t)
**EDIT**
The answer of rws prompts me to note the following:
u = SR.var('u')
gf = exp(u)*(bessel_I(0, 2*u)-bessel_I(1, 2*u))
s = gf.series(u,6).simplify_full()
R.<x> = PowerSeriesRing(SR)
t = R(s).ogf_to_egf()
print t.parent()
print t
The answer is:
Power Series Ring in x over Symbolic Ring
1/20*u^5 + 1/8*u^4 + 1/6*u^3 + 1/2*u^2 + Order(u^6) + 1
OK, but now delete the transformation ogf_to_egf() in the above code and the answer is -- the same!
Mon, 24 Nov 2014 14:31:49 +0100https://ask.sagemath.org/question/24968/coefficients-in-polynomial-ring-over-symbolic-ring/Answer by rws for <p>Consider </p>
<pre><code>x = SR.var('x')
gf = exp(x)*(bessel_I(0, 2*x)-bessel_I(1, 2*x))
t = gf.series(x, 6).simplify_full()
print t.coefficients()
Q.<x> = PolynomialRing(SR)
Q(t)
</code></pre>
<p>The output is:</p>
<pre><code>[[Order(x^6) + 1, 0], [1/2, 2], [1/6, 3], [1/8, 4], [1/20, 5]]
1/20*x^5 + 1/8*x^4 + 1/6*x^3 + 1/2*x^2 + Order(x^6) + 1
</code></pre>
<p>'Order(x^6)' is a coefficient of a polynomial?</p>
<p><strong>Solution</strong> by kcrisman:</p>
<pre><code>x = SR.var('x')
gf = exp(x)*(bessel_I(0, 2*x)-bessel_I(1, 2*x))
t = gf.series(x, 6).truncate().simplify_full()
print t.coefficients()
Q.<x> = PolynomialRing(SR)
Q(t)
</code></pre>
<p><strong>EDIT</strong> </p>
<p>The answer of rws prompts me to note the following:</p>
<pre><code>u = SR.var('u')
gf = exp(u)*(bessel_I(0, 2*u)-bessel_I(1, 2*u))
s = gf.series(u,6).simplify_full()
R.<x> = PowerSeriesRing(SR)
t = R(s).ogf_to_egf()
print t.parent()
print t
</code></pre>
<p>The answer is:</p>
<pre><code>Power Series Ring in x over Symbolic Ring
1/20*u^5 + 1/8*u^4 + 1/6*u^3 + 1/2*u^2 + Order(u^6) + 1
</code></pre>
<p>OK, but now delete the transformation ogf_to_egf() in the above code and the answer is -- the same!</p>
https://ask.sagemath.org/question/24968/coefficients-in-polynomial-ring-over-symbolic-ring/?answer=25010#post-id-25010There are practically three bugs:
- there is no SR.function that gets the coefficients of SR.series; rather, `coeffs` etc give confusing results; `truncate` must be prepended manually. This is [trac #17399](http://trac.sagemath.org/ticket/17399).
- even if truncated, the polynomial cannot be converted to a PowerSeries(SR) or Polynomial(SR). The whole symbolic expression is taken as a constant. Your usage of `x` for everything disguises this. This is [trac #16203](http://trac.sagemath.org/ticket/16203).
For the problem with `simplify_full` I have opened [trac #17400](http://trac.sagemath.org/ticket/17400) but I'm not sure if that ticket is really separate.Wed, 26 Nov 2014 11:32:46 +0100https://ask.sagemath.org/question/24968/coefficients-in-polynomial-ring-over-symbolic-ring/?answer=25010#post-id-25010Answer by kcrisman for <p>Consider </p>
<pre><code>x = SR.var('x')
gf = exp(x)*(bessel_I(0, 2*x)-bessel_I(1, 2*x))
t = gf.series(x, 6).simplify_full()
print t.coefficients()
Q.<x> = PolynomialRing(SR)
Q(t)
</code></pre>
<p>The output is:</p>
<pre><code>[[Order(x^6) + 1, 0], [1/2, 2], [1/6, 3], [1/8, 4], [1/20, 5]]
1/20*x^5 + 1/8*x^4 + 1/6*x^3 + 1/2*x^2 + Order(x^6) + 1
</code></pre>
<p>'Order(x^6)' is a coefficient of a polynomial?</p>
<p><strong>Solution</strong> by kcrisman:</p>
<pre><code>x = SR.var('x')
gf = exp(x)*(bessel_I(0, 2*x)-bessel_I(1, 2*x))
t = gf.series(x, 6).truncate().simplify_full()
print t.coefficients()
Q.<x> = PolynomialRing(SR)
Q(t)
</code></pre>
<p><strong>EDIT</strong> </p>
<p>The answer of rws prompts me to note the following:</p>
<pre><code>u = SR.var('u')
gf = exp(u)*(bessel_I(0, 2*u)-bessel_I(1, 2*u))
s = gf.series(u,6).simplify_full()
R.<x> = PowerSeriesRing(SR)
t = R(s).ogf_to_egf()
print t.parent()
print t
</code></pre>
<p>The answer is:</p>
<pre><code>Power Series Ring in x over Symbolic Ring
1/20*u^5 + 1/8*u^4 + 1/6*u^3 + 1/2*u^2 + Order(u^6) + 1
</code></pre>
<p>OK, but now delete the transformation ogf_to_egf() in the above code and the answer is -- the same!</p>
https://ask.sagemath.org/question/24968/coefficients-in-polynomial-ring-over-symbolic-ring/?answer=24970#post-id-24970I think that perhaps our various Maxima things in `simplify_full` can't handle power series notation from Pynac, note how `+1` so it is taking `Order(x^6)` as an unknown constant term along with `+1`. What I would do is truncate the order out first and then do simplifications.Mon, 24 Nov 2014 15:37:57 +0100https://ask.sagemath.org/question/24968/coefficients-in-polynomial-ring-over-symbolic-ring/?answer=24970#post-id-24970Comment by Peter Luschny for <p>I think that perhaps our various Maxima things in <code>simplify_full</code> can't handle power series notation from Pynac, note how <code>+1</code> so it is taking <code>Order(x^6)</code> as an unknown constant term along with <code>+1</code>. What I would do is truncate the order out first and then do simplifications.</p>
https://ask.sagemath.org/question/24968/coefficients-in-polynomial-ring-over-symbolic-ring/?comment=24974#post-id-24974Do you consider this as a defect?Mon, 24 Nov 2014 16:08:33 +0100https://ask.sagemath.org/question/24968/coefficients-in-polynomial-ring-over-symbolic-ring/?comment=24974#post-id-24974Comment by kcrisman for <p>I think that perhaps our various Maxima things in <code>simplify_full</code> can't handle power series notation from Pynac, note how <code>+1</code> so it is taking <code>Order(x^6)</code> as an unknown constant term along with <code>+1</code>. What I would do is truncate the order out first and then do simplifications.</p>
https://ask.sagemath.org/question/24968/coefficients-in-polynomial-ring-over-symbolic-ring/?comment=24977#post-id-24977I don't know. Probably we should be able to deal with this, yes. Do you want to open a ticket for sending power series to Maxima properly? (We may already, maybe it just doesn't know what to do in the simplification routines - I haven't looked at this at all, and won't have time in the near future. But you should open the ticket, anyway.)Mon, 24 Nov 2014 17:23:12 +0100https://ask.sagemath.org/question/24968/coefficients-in-polynomial-ring-over-symbolic-ring/?comment=24977#post-id-24977