Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

A nice one...

Consider

sage: R.<x>=InfinitePolynomialRing(QQ)
sage: f=R(x[1]^3)

Note that :

sage: [u.parent() for u in f.variables()]
[Multivariate Polynomial Ring in x_2, x_1, x_0 over Rational Field]

(yes, I played with R a bit...) contrasting with:

sage: x[1].parent()
Infinite polynomial ring in x over Rational Field

Hence the error you noticed. However :

sage: x[1] in f.variables()
True

It is there ; you just have to find it :

sage: f.variables().index(x[1])
0

Hence the (awkward) :

sage: f.derivative(f.variables()[f.variables().index(x[1])])
3*x_1^2

A better way would be to cast x[1] to the proper class. Finding which isn't intuitive...