Opened 5 years ago

Last modified 4 years ago

#24861 needs_work defect

Option to hold for derivative

Reported by: Vaibhav Karve Owned by:
Priority: trivial Milestone: sage-8.4
Component: calculus Keywords: hold
Cc: Merged in:
Authors: Ralf Stephan Reviewers:
Report Upstream: N/A Work issues:
Branch: u/rws/option_to_hold_for_derivative (Commits, GitHub, GitLab) Commit: 453cf14cdc3615d781d0dcd57daa95b9e45d5b5a
Dependencies: Stopgaps:

Status badges


It would be nice to have the output of

(x^3).diff(x, hold=True)

look like

$$ \frac{\partial}{\partial x}x^3 $$

Change History (5)

comment:1 Changed 5 years ago by Ralf Stephan

Although we don't exactly have already a ticket for this, see the related #17445 and #15021.

comment:2 Changed 5 years ago by Ralf Stephan

Branch: u/rws/option_to_hold_for_derivative

comment:3 Changed 5 years ago by git

Commit: 453cf14cdc3615d781d0dcd57daa95b9e45d5b5a

Branch pushed to git repo; I updated commit sha1. New commits:

453cf1424861: handle multi diffs

comment:4 Changed 5 years ago by Ralf Stephan

Authors: Ralf Stephan
Milestone: sage-featuresage-8.2
Status: newneeds_review

Thanks for the report. This will be a useful addition to Sage.

comment:5 Changed 4 years ago by Bryan Gin-ge Chen

Milestone: sage-8.2sage-8.4
Status: needs_reviewneeds_work

I agree this would be a nice addition; thanks for addressing this. Here are some comments.

In src/sage/functions/

  • Something like (x).diff(x*x, hold=True) returns diff(x, x^2) instead of an error. Note also that latex((x).diff(x*x, hold=True)) causes a segfault.
  • The error message wrong argument in diff could be made more helpful; perhaps something like all arguments to diff must be symbols or numerical values. This should be tested as well.
  • The LaTeX output should include parentheses around the expression (probably with \left and \right), otherwise something like latex((x^3+y).diff(x,2,y,2, hold=True)) returns {\frac{\partial^{4}}{{\partial x^2}{\partial y^2}} x^{3} + y} which is incorrect.

In src/sage/symbolic/expression.pyx:

  • the hold parameter should be added to the docstring of derivative. I also noticed a typo in the first line of the docstring as well: this expressions -> this expression.
Note: See TracTickets for help on using tickets.