Opened 4 years ago

Last modified 4 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)

**Note:**See TracTickets for help on using tickets.

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

But there is room for improvement, for sure.