Opened 3 years ago

# Option to hold for derivative

Reported by: Owned by: gh:vaibhavkarve trivial sage-8.4 calculus hold Ralf Stephan N/A u/rws/option_to_hold_for_derivative (Commits) 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 3 years ago by rws

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

### comment:2 Changed 3 years ago by rws

• Branch set to u/rws/option_to_hold_for_derivative

### comment:3 Changed 3 years ago by git

• Commit set to 453cf14cdc3615d781d0dcd57daa95b9e45d5b5a

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

 ​453cf14 24861: handle multi diffs

### comment:4 Changed 3 years ago by rws

• Authors set to Ralf Stephan
• Milestone changed from sage-feature to sage-8.2
• Status changed from new to needs_review

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

### comment:5 Changed 2 years ago by gh-bryangingechen

• Milestone changed from sage-8.2 to sage-8.4
• Status changed from needs_review to 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.