Ask Your Question
0

How to differentiate in the Laurent polynomial ring?

asked 2013-11-23 01:17:33 -0500

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 02:24:12 -0500

Luca gravatar image

updated 2013-11-23 02:25:03 -0500

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 10:42:57 -0500 )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 11:50:40 -0500 )edit

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

petropolis gravatar imagepetropolis ( 2013-11-24 22:05:07 -0500 )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 03:07:20 -0500 )edit
Luca gravatar imageLuca ( 2013-11-25 03:16:18 -0500 )edit
0

answered 2013-11-23 23:18:47 -0500

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 06:37:58 -0500 )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 10:45:05 -0500 )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 01:17:33 -0500

Seen: 189 times

Last updated: Nov 23 '13