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, 25 Nov 2013 03:16:18 -0600How to differentiate in the Laurent polynomial ring?http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/ R.<x> = LaurentPolynomialRing(ZZ,1); R
f = x^2 - 2*x^-2
diff(f,x)
Expected: 2*x+4/x^3
TypeError: no canonical coercion from Univariate Laurent
Polynomial Ring in x over Integer Ring to Symbolic Ring.
Sat, 23 Nov 2013 01:17:33 -0600http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/Answer by Luca for <pre><code>R.<x> = LaurentPolynomialRing(ZZ,1); R
f = x^2 - 2*x^-2
diff(f,x)
</code></pre>
<p>Expected: 2*x+4/x^3</p>
<p>TypeError: no canonical coercion from Univariate Laurent
Polynomial Ring in x over Integer Ring to Symbolic Ring.</p>
http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?answer=15722#post-id-15722I don't think this is implemented yet. You can make a feature request for it on the bug tracking system <http://trac.sagemath.org>.Sat, 23 Nov 2013 02:24:12 -0600http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?answer=15722#post-id-15722Comment by Luca for <p>I don't think this is implemented yet. You can make a feature request for it on the bug tracking system <a href="http://trac.sagemath.org">http://trac.sagemath.org</a>.</p>
http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16625#post-id-16625The antiderivative is more problematic: what would the parent of `integral(1/x)` be? If you need this, you're better off with the symbolic ring.Mon, 25 Nov 2013 03:07:20 -0600http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16625#post-id-16625Comment by petropolis for <p>I don't think this is implemented yet. You can make a feature request for it on the bug tracking system <a href="http://trac.sagemath.org">http://trac.sagemath.org</a>.</p>
http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16627#post-id-16627That would be great. And please add also integral(f,x), the antiderivative.Sun, 24 Nov 2013 22:05:07 -0600http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16627#post-id-16627Comment by petropolis for <p>I don't think this is implemented yet. You can make a feature request for it on the bug tracking system <a href="http://trac.sagemath.org">http://trac.sagemath.org</a>.</p>
http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16632#post-id-16632Hm, would this be worthwhile and have a chance to be done? What do longtime contributors think?Sun, 24 Nov 2013 10:42:57 -0600http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16632#post-id-16632Comment by Luca for <p>I don't think this is implemented yet. You can make a feature request for it on the bug tracking system <a href="http://trac.sagemath.org">http://trac.sagemath.org</a>.</p>
http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16630#post-id-16630Doesn't look very hard to implement. I'd say it has a fair chance of being done rapidly. I personally wouldn't mind adding the method as soon as I have a spare hour.Sun, 24 Nov 2013 11:50:40 -0600http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16630#post-id-16630Comment by Luca for <p>I don't think this is implemented yet. You can make a feature request for it on the bug tracking system <a href="http://trac.sagemath.org">http://trac.sagemath.org</a>.</p>
http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16624#post-id-16624This is now <http://trac.sagemath.org/ticket/15450>Mon, 25 Nov 2013 03:16:18 -0600http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16624#post-id-16624Answer by gundamlh for <pre><code>R.<x> = LaurentPolynomialRing(ZZ,1); R
f = x^2 - 2*x^-2
diff(f,x)
</code></pre>
<p>Expected: 2*x+4/x^3</p>
<p>TypeError: no canonical coercion from Univariate Laurent
Polynomial Ring in x over Integer Ring to Symbolic Ring.</p>
http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?answer=15724#post-id-15724Hey I don't understand.. But it is perhaps the answer.
sage: R.<x> = LaurentPolynomialRing(ZZ,1); R
Univariate Laurent Polynomial Ring in x over Integer Ring
sage: f(x) = x^2 - 2*x^-2
sage: f.diff(x)
x |--> 2*x + 4/x^3
I hope it helps.
----------
sage: R.<x> = LaurentPolynomialRing(ZZ,1); R
Univariate Laurent Polynomial Ring in x over Integer Ring
sage: f = x^2 - 2*x^-2
sage: ff = f; ff
x^2 - 2*x^-2
sage: f(x) = x^2 - 2*x^-2
sage: f
x |--> x^2 - 2/x^2
sage: diff(ff,x)
0
sage: ff
x^2 - 2*x^-2
sage: f.diff(x)
x |--> 2*x + 4/x^3
sage: diff?
sage: diff(ff)
0
The way of defining the "ff" is not good. Do we have to define a polynomial like this, in order to compute its derivative conveniently?
p(x) = x**2 + a1*x + a2
----------
Thanks in advance!
Sat, 23 Nov 2013 23:18:47 -0600http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?answer=15724#post-id-15724Comment by Luca for <p>Hey I don't understand.. But it is perhaps the answer.</p>
<pre><code>sage: R.<x> = LaurentPolynomialRing(ZZ,1); R
Univariate Laurent Polynomial Ring in x over Integer Ring
sage: f(x) = x^2 - 2*x^-2
sage: f.diff(x)
x |--> 2*x + 4/x^3
</code></pre>
<p>I hope it helps.</p>
<hr/>
<pre><code>sage: R.<x> = LaurentPolynomialRing(ZZ,1); R
Univariate Laurent Polynomial Ring in x over Integer Ring
sage: f = x^2 - 2*x^-2
sage: ff = f; ff
x^2 - 2*x^-2
sage: f(x) = x^2 - 2*x^-2
sage: f
x |--> x^2 - 2/x^2
sage: diff(ff,x)
0
sage: ff
x^2 - 2*x^-2
sage: f.diff(x)
x |--> 2*x + 4/x^3
sage: diff?
sage: diff(ff)
0
</code></pre>
<p>The way of defining the "ff" is not good. Do we have to define a polynomial like this, in order to compute its derivative conveniently?</p>
<pre><code>p(x) = x**2 + a1*x + a2
</code></pre>
<hr/>
<p>Thanks in advance!</p>
http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16634#post-id-16634Your answer uses symbolic variables, rather than Laurent polynomials. It is a good workaround, given that Laurent polynomials do not have a derivative method. Note that with ordinary polynomials you do not have to use symbolics to differentiate:
sage: R = PolynomialRing(QQ, 'x')
sage: x = R.gen()
sage: diff(x^2)
2*x
sage: (x^2).derivative()
2*xSun, 24 Nov 2013 06:37:58 -0600http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16634#post-id-16634Comment by petropolis for <p>Hey I don't understand.. But it is perhaps the answer.</p>
<pre><code>sage: R.<x> = LaurentPolynomialRing(ZZ,1); R
Univariate Laurent Polynomial Ring in x over Integer Ring
sage: f(x) = x^2 - 2*x^-2
sage: f.diff(x)
x |--> 2*x + 4/x^3
</code></pre>
<p>I hope it helps.</p>
<hr/>
<pre><code>sage: R.<x> = LaurentPolynomialRing(ZZ,1); R
Univariate Laurent Polynomial Ring in x over Integer Ring
sage: f = x^2 - 2*x^-2
sage: ff = f; ff
x^2 - 2*x^-2
sage: f(x) = x^2 - 2*x^-2
sage: f
x |--> x^2 - 2/x^2
sage: diff(ff,x)
0
sage: ff
x^2 - 2*x^-2
sage: f.diff(x)
x |--> 2*x + 4/x^3
sage: diff?
sage: diff(ff)
0
</code></pre>
<p>The way of defining the "ff" is not good. Do we have to define a polynomial like this, in order to compute its derivative conveniently?</p>
<pre><code>p(x) = x**2 + a1*x + a2
</code></pre>
<hr/>
<p>Thanks in advance!</p>
http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16631#post-id-16631Comment the line "R.<x> = LaurentPolynomialRing(ZZ,1)" and you get the same result. Thus you do not work with the LaurentPolynomialRing.Sun, 24 Nov 2013 10:45:05 -0600http://ask.sagemath.org/question/10767/how-to-differentiate-in-the-laurent-polynomial-ring/?comment=16631#post-id-16631