Ticket #4202 (closed enhancement: fixed)

Opened 5 years ago

Last modified 5 years ago

[with patch, positive review] latex derivatives of symbolic functions nicely

Reported by: jason Owned by: burcin
Priority: major Milestone: sage-3.1.3
Component: calculus Keywords:
Cc: Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

This patch makes it so that symbolic functions attempt to call maxima to get a latex representation before printing out the default functionname(arguments) notation.

Here is some Sage code that did derivative printing. I post it here since this code tries to intelligently print partials versus total derivatives, while maxima's seems to only print total derivative "d"s. If there is interest, we can include this as part of the _latex_ function.

        if self._f._name == 'diff':
            if len(self._args[0].variables())==1:
                d_latex = "d"
            else:
                d_latex = "\\partial"

            variables = [(self._args[2*i+1]._latex_(), self._args[2*i+2]) 
                         for i in xrange((len(self._args)-1)/2)]
            variables_latex = ''.join([d_latex+var if power==1 else d_latex+var+"^%r"%power
                                       for var,power in variables])


            order = sum([power for var,power in variables])
            if order == 1:
                order_latex = ""
            else:
                order_latex = "^%r"%order
        
            return "\\frac{%s%s}{%s}(%s)"%(d_latex,
                                              order_latex,
                                              variables_latex,
                                              self._args[0]._latex_())

Attachments

diff-latex.patch Download (1.7 KB) - added by jason 5 years ago.

Change History

Changed 5 years ago by jason

comment:1 Changed 5 years ago by mhansen

  • Summary changed from latex derivatives of symbolic functions nicely to [with patch, positive review] latex derivatives of symbolic functions nicely

Nice job. Looks good to me.

comment:2 Changed 5 years ago by mabshoff

  • Status changed from new to closed
  • Resolution set to fixed

Merged in Sage 3.1.3.alpha2

Note: See TracTickets for help on using tickets.