Opened 5 years ago

# Option to hold for derivative

Reported by: Owned by: Vaibhav Karve trivial sage-8.4 calculus hold Ralf Stephan N/A u/rws/option_to_hold_for_derivative 453cf14cdc3615d781d0dcd57daa95b9e45d5b5a

### Description

It would be nice to have the output of

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


look like

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


### 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:

 ​453cf14 24861: handle multi diffs

### comment:4 Changed 5 years ago by Ralf Stephan

Authors: → Ralf Stephan sage-feature → sage-8.2 new → needs_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.2 → sage-8.4 needs_review → needs_work

In src/sage/functions/other.py:

• 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.