Ask Your Question
0

How to differentiate in the Laurent polynomial ring?

asked 2013-11-23 08:17:33 +0100

petropolis gravatar image
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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-11-23 09:24:12 +0100

Luca gravatar image

updated 2013-11-23 09:25:03 +0100

I don't think this is implemented yet. You can make a feature request for it on the bug tracking system http://trac.sagemath.org.

edit flag offensive delete link more

Comments

Hm, would this be worthwhile and have a chance to be done? What do longtime contributors think?

petropolis gravatar imagepetropolis ( 2013-11-24 17:42:57 +0100 )edit

Doesn'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.

Luca gravatar imageLuca ( 2013-11-24 18:50:40 +0100 )edit

That would be great. And please add also integral(f,x), the antiderivative.

petropolis gravatar imagepetropolis ( 2013-11-25 05:05:07 +0100 )edit

The 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.

Luca gravatar imageLuca ( 2013-11-25 10:07:20 +0100 )edit
Luca gravatar imageLuca ( 2013-11-25 10:16:18 +0100 )edit
0

answered 2013-11-24 06:18:47 +0100

gundamlh gravatar image

Hey 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!

edit flag offensive delete link more

Comments

Your 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*x

Luca gravatar imageLuca ( 2013-11-24 13:37:58 +0100 )edit

Comment the line "R.<x> = LaurentPolynomialRing(ZZ,1)" and you get the same result. Thus you do not work with the LaurentPolynomialRing.

petropolis gravatar imagepetropolis ( 2013-11-24 17:45:05 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-11-23 08:17:33 +0100

Seen: 630 times

Last updated: Nov 24 '13