Opened 4 years ago

Last modified 3 years ago

#24861 needs_work defect

Option to hold for derivative

Reported by: gh:vaibhavkarve 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 4 years ago by rws

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

comment:2 Changed 4 years ago by rws

  • Branch set to u/rws/option_to_hold_for_derivative

comment:3 Changed 4 years ago by git

  • Commit set to 453cf14cdc3615d781d0dcd57daa95b9e45d5b5a

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

453cf1424861: handle multi diffs

comment:4 Changed 4 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 3 years ago by gh-bryangingechen

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