#5711: [with patch, needs review] Enhanced Typesetting of Symbolic Functions
-------------------------+--------------------------------------------------
 Reporter:  gmhossain    |       Owner:  cwitty                                 
       
     Type:  enhancement  |      Status:  new                                    
       
 Priority:  major        |   Milestone:  sage-4.1                               
       
Component:  symbolics    |    Keywords:  Enhance Typesetting, LaTeX, Symbolic 
Functions
 Reviewer:               |      Author:                                         
       
   Merged:               |  
-------------------------+--------------------------------------------------

Old description:

> 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:
>
> {{{
> var('t');
> hubble(t) = function('hubble',t)
> hubble(t).set_latex('\\mathcal{H}')
>
> #To reset custom LaTeX expression
> hubble(t).set_latex()
> }}}
>
> (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
>
> {{{
> 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)
> }}}
>

> (7) '''[New in the rebased patch]'''  The rebased patch resolves
> the issue
>
> http://trac.sagemath.org/sage_trac/ticket/6268

New description:

 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:

 {{{
 var('t');
 hubble(t) = function('hubble',t)
 hubble(t).set_latex('\\mathcal{H}')

 #To reset custom LaTeX expression
 hubble(t).set_latex()
 }}}

 (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

 {{{
 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)
 }}}


 (7) '''[New in the rebased patch]'''  The rebased patch resolves
 the issue

 http://trac.sagemath.org/sage_trac/ticket/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}).

--

Comment(by gmhossain):

 Burcin: I have updated the patch as you suggested. List of changes is
 given in the description.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5711#comment:13>
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to