#5711: [with patch, needs work] Enhanced Typesetting of Symbolic Functions
-------------------------+--------------------------------------------------
Reporter: gmhossain | Owner: cwitty
Type: enhancement | Status: new
Priority: major | Milestone: sage-4.0.2
Component: symbolics | Keywords: Enhance Typesetting, LaTeX, Symbolic
Functions
Reviewer: | Author:
Merged: |
-------------------------+--------------------------------------------------
Changes (by burcin):
* component: misc => symbolics
Comment:
Hi Golam,
Thanks for your continued work on this. I see that your patch improves the
typesetting of symbolic functions dramatically. I believe with a few
improvements it would fit better in the new symbolics framework.
Here is my referee report:
Quotes from the description:
>
> (2) Functions such as "diff", "integrate", "limit", "conjugate",
> "laplace", "inverse_laplace" are now typeset within Sage itself.
>
> Ex: integrate(f(x),x) => \int f(x) dx
These should be handled using the custom printing facilities of
`sage.symbolic.function.SFunction`. Special casing them in the new
`latex_symbolic_function()` function is not scalable. This approach would
also make the checks for the number of arguments as well as the calls to
`_symbolic_function_default_latex_()` in each of these functions
redundant.
I see that there is already a `_limit` function defined in
`sage/calculus/calculus.py`. I think the best solution for the short term
would be to put these printing functions there, and give them as an
argument to the `SFunction` constructor.
Conjugates are already printed as:
{{{
sage: latex(x.conjugate())
\bar{x}
}}}
Why is `\overline` better?
> (6) '''[New in the rebased patch]''' New symbolics uses "D"
> format for derivatives instead of old "diff" format.
> The rebased patch typesets symbolic derivatives in old "diff" format by
default as in this format typeset version looks similar to those found in
text books, journals.
>
> However see this thread for known limitations of current conversion
between these two formats
> http://groups.google.com/group/sage-
devel/browse_thread/thread/7479c3eeb96348a2
>
> One can switch between two typesetting format as follows
>
> {{{
> f(x) = function('f',x)
> g = diff(f(x),x)
> latex(g)
> \frac{d f\left(x\right)}{d x}
> # Switch to D format
> sage.symbolic.pynac.typeset_d_as_diff=False
> latex(g)
> D[0]f\left(x\right)
> }}}
I believe this issue needs more debate, preferably with examples of how
Maple and MMA handle this problem. I will post a new message about this to
sage-devel soon. For now, I suggest we split this to a different ticket.
> (1) Symbolics functions with name in Greek letters (with possible
> suffixes), are typeset nicely in LaTeX.
>
> Ex: psi(x) => \psi(x)
> f0(x) => f_0(x)
Can't this be handled by a call to the new `latex_function_name()` from
`sage.symbolic.pynac.py_latex_function_pystring()`?
> (3) Default (fall-back) typesetting for unknown functions (as
> in Maxima).
>
> Ex: myfn(x) => {\it myfn}(x)
We have the GiNaC convention of falling back to `\mbox` at the moment.
Previously, maxima didn't do anything for function names with one
variable, and added an `\it`:
{{{
sage: version()
'Sage Version 3.4.2, Release Date: 2009-05-05'
sage: var('a')
a
sage: f = function('f')
sage: latex(f(a))
f\left(a\right)
}}}
As you mention in the docstring for `latex_function_name()`, there is
considerable code duplication between this function and
`latex_variable_name()`. Your previous response to my question about the
differences between these two functions is here:
http://groups.google.com/group/sage-devel/msg/071207efa39c5356
It seems that your goal of returning a different response as default
behavior can be achieved by passing a parameter to the `latex_varify()`
calls at the end of `latex_variable_name()`. Is there a reason why the
further recursions performed by `latex_variable_name()` are not relevant
for function names? In any case, the string processing code in
`latex_variable_name()` shouldn't be duplicated.
> (7) '''[New in the rebased patch]''' The rebased patch resolves
> the issue
>
> http://trac.sagemath.org/sage_trac/ticket/6268
This seems to be caused by a thinko on my part. It can be fixed by
modifying lines 416-149 in `sage/symbolic/pynac.pyx`. You seem to do
something similar at the end of `latex_symbolic_function()` and
`_symbolic_function_default_latex_()` functions.
Overall I think the patch looks very crowded and confusing. With the
changes suggested above,
* the new functions `latex_symbolic_function()`,
`_symbolic_function_default_latex_()`, `_args_latex_()`, can be
eliminated.
* derivative related functions `latex_d_derivative()` and
`_derivative_latex_()` should be split to a new ticket.
* specialized printing functions `_integrate_latex_()`,
`_inverse_laplace_latex_()`, `_laplace_latex_()`, `_limit_latex_()` should
be moved to `sage/calculus/calculus.py` and hooked up to the right
`sage.symbolic.function.SFunction` instance.
* `_conjugate_latex_()` doesn't seem necessary.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5711#comment:11>
Sage <http://sagemath.org/>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---