New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhanced Typesetting of Symbolic Functions #5711
Comments
comment:3
burcin: do you want to review this? Does the move to the new symbolics affect this patch? |
comment:4
Patch doesn't apply cleanly against 4.0.1. |
comment:5
Replying to @jhpalmieri:
Yes, recent switch to new symbolics has affected this patch quite a bit. |
This comment has been minimized.
This comment has been minimized.
comment:7
This is really impressive. I assume that stan s and the others will want to review this more since they would use it more intensely and understand LaTeX better than I do, but I threw it a lot of stuff and the only "problems" I found were additional cases one might want, which could easily be a separate ticket after this is merged. The integrals, limits, Laplace, derivatives work out nice now, as does the option for D.
|
comment:8
This patch does not pass doctests on sage.math:
Should be easy enough to fix. |
comment:9
Thanks! I have fixed these two doctest failure and updated the rebased patch. |
comment:10
Thanks kcrisman! As you have suggested, I would also prefer to fix only the blockers
This seems to be a bug for "exp" function. Other functions such as "abs", "sin" etc work fine. I have posted |
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:
These should be handled using the custom printing facilities of I see that there is already a Conjugates are already printed as:
Why is
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.
Can't this be handled by a call to the new
We have the GiNaC convention of falling back to
As you mention in the docstring for 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
This seems to be caused by a thinko on my part. It can be fixed by modifying lines 416-149 in Overall I think the patch looks very crowded and confusing. With the changes suggested above,
|
comment:12
Thanks Burcin for your detailed review. See below for my responses. I would be happy to
I fully agree! However, does new symbolics has such framework ready for the mentioned functions?
Could you please give an short example for such construction (my current understanding What is your "long-term" solution? Why is it better to put these functions in calculus/calculus.py
"\bar" is ok for variable but is insufficient for symbolic functions. Please try the
then you will see the reason yourself.
Sure, I will open a new ticket for this.
Provided all other symbolic "functions" ("integrate",...) have been typeset
Frankly, it is disappointing to see another inconsistent typesetting. Why should a function named "sin" should be typseset as "\sin" (=>"\rm sin")
So as in this patch! Though, I wanted to use "\rm" as {\rm myfunc} but decided to
I agree that we should avoid duplication of code.
In physics, we often use functions such as "f_{\alpha\beta}". In sage, if I use However I guees, thats my own preference and I shouldn't argue anymore on this. I will remove latex_function_name() and use latex_variable_name() instead. |
comment:13
Burcin: I have updated the patch as you suggested. List of changes is given in the description. |
This comment has been minimized.
This comment has been minimized.
Attachment: trac_5711-doctest_fixes.patch.gz doctest fixes |
comment:14
Thanks Golam. The patch looks good to me. I added a small patch that fixes doctests in two places. Only apply
|
Merged: sage-4.1.alpha0 |
Reviewer: Burcin Erocal |
Author: Golam Mortuza Hossain |
comment:16
Replying to @kcrisman:
[Snip] Great work, anyway, and many thanks to those that invested time and effort into improving the typesetting in Sage! |
comment:17
Replying to @sagetrac-schymans:
Yes but in a new avatar! The new method would be more powerful. The patch is |
Here is a patch that enhances current typesetting capability
of symbolic functions within sage.
This issue has been under a long discussion in the thread
http://groups.google.com/group/sage-devel/browse_thread/thread/a51f269f057d8223/536b4ef2493bb20c
Note: Switch to new symbolics has caused some functions to be changed
Main enhancements are:
(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)
(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
(3) Default (fall-back) typesetting for unknown functions (as
in Maxima).
Ex: myfn(x) => {\it myfn}(x)
(4) [ This is diasbled in new symbolics. However, equivalent feature will be available in new symbolics ]
Allows users to define their own/custom LaTeX expression
for any symbolic functions via a new method "set_latex()" for
the class SymbolicFunctionEvaluation.
Ex:
(5) [ This has been disabled in new Symbolics as SymbolicVariable class has changed ]
If the arguments of a symbolic function are all symbolic
variables then typesetting will avoid using \left(, \right).
Ex: Phi(x,y) => \Phi(x, y) (if x,y are symbolic vars)
(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
(7) [New in the rebased patch] The rebased patch resolves
the issue
#6268
[Update: in v3 (4.0.2) ]
As suggested by Burcin in his referee report, following changes are made in the patch:
(1) Typesetting of "diff" is moved to a new ticket #6344
(2) Four helper functions limit_latex(), integrate_latex(), laplace_latex() and inverse_laplace_latex() have been moved to calculus/calculus.py. Then they are hooked to the instances of SFunction class by using dummy functions for better integration with the new symbolics.
(3) Four earlier functions latex_symbolic_function(), symbolic_function_default_latex(), args_latex(), _conjugate_latex() are removed.
(4) latex_function_name() is also replaced as the updated latex_variable_name() is augmented to take a new flag "is_fname". This will ensure that same typesetting convention is followed for both known functions such as \sin (:= {\rm sin}), \cos (:= {\rm cos}) and user defined function names such as "mysin" (=> {\rm mysin}).
CC: @burcin @jasongrout @jhpalmieri @sagetrac-schymans
Component: symbolics
Keywords: Enhance Typesetting, LaTeX, Symbolic Functions
Author: Golam Mortuza Hossain
Reviewer: Burcin Erocal
Merged: sage-4.1.alpha0
Issue created by migration from https://trac.sagemath.org/ticket/5711
The text was updated successfully, but these errors were encountered: