Opened 4 years ago

Last modified 3 years ago

#20812 new enhancement

derivative of integer wrt to variable in polynomial ring should belong to that ring, not symbolic ring

Reported by: dgulotta Owned by:
Priority: major Milestone: sage-7.3
Component: calculus Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

If I try to take the derivative of an integer (or nonzero rational, or integer mod n), then the result is an element of the symbolic ring:

sage: R.<x>=ZZ[]
sage: derivative(0,x).parent()
Symbolic Ring

It seems like it would be more natural for the returned value to belong to the ring containing x instead.

This may seem kind of pedantic, but it did trip me up when I was working with a list of polynomials, some of which were constant, and things were getting cast to Expression unexpectedly.

I am not particularly familiar with the Sage codebase, but I am attaching a patch that seems to fix the issue.

Attachments (1)

functional.py.patch (871 bytes) - added by dgulotta 4 years ago.

Download all attachments as: .zip

Change History (2)

Changed 4 years ago by dgulotta

comment:1 Changed 3 years ago by chapoton

If you take care to use the correct zero, this just works:

sage: R.zero().derivative(x).parent()
Univariate Polynomial Ring in x over Integer Ring

But there is room for improvement, for sure.

Note: See TracTickets for help on using tickets.