Correcting priority issues in mactex.lisp



Hi all on this thread,

I made a mistake in explaining the case of sum(). Let me be more  
specific
on this issue.

Looking at the existing implementation of tex-sum(), I noticed that the
code does NOT consider the right priority of %sum and the left priority
of mplus. I think this is a bug because the sole purpose of operator  
priorities
defined in mactex.lisp is to determine the necessity of parentheses on  
generating
tex code, and should be considered at any cases like this.

My modification to tex-sum() is to perform correctly the comparison of
the priorities.


The issue h*cos(a) being displayed as "cos a h" is more subjective,  
since,
priorities in mind, I can correctly read and parse the expression.  My
modification is to change the priority of trig functions which is simply
reflecting my personal preference.


I actually committed both modifications to the CVS before any comments
appeared on the mailing list. As I explained, the tex-sum() change  
should
be still valid. But I will withdraw the modification for trig function  
priority
change.

BTW, some people proposed to branch mactex.lisp for imaxima. I don't
think that makes sense since there is no reason for differentiating the
output of tex() from imaxima rendering. The single issue here is how to
output maxima expressions in LaTeX command.

Yasuaki Honda, Chiba, Japan

On 2009/05/25, at 0:40, Yasuaki Honda wrote:

> Dear all,
>
> I want to fix issues in mactex.lisp regarding how to put parenthes
> when tex() function is used to generate latex commands. These
> issues also occur in imaxima since it solely depends on tex()
> function.
>
> I would like to hear any opinions from you for this before commit.
>
> 1) h*cos(a) is displayed as "cos a h"
> This is confusing and I want to change the priority of trig functions
> to 119 (rather than today's 130) so that the output looks like
> "(cos a) h". 119 is chosen to be one less than 120, which is the
> priority
> of mtimes.
>
> 2) sum(a[n]+b[n],n,1,k) is displayed like
>
>                                k
>                               ====
>                               \
> (%o6)                            >    b  + a
>                               /       n    n
>                               ====
>                               n = 1
>
> in latex. I think b[n]+a[n] should be parenthed in sum. The same thing
> happens in product(), too. I want to modify tex-sum() so that the
> priority of
> mplus and %sum are considered.
>
> The actual diff attached below is very small. If no arguments, I would
> like
> to commit within a day or two.
>
> Yasuaki Honda
>
> RCS file: /cvsroot/maxima/maxima/src/mactex.lisp,v
> retrieving revision 1.67
> diff -r1.67 mactex.lisp
> 660,661c660,664
> < 	;; gotta be one of those above
> < 	(s1 (tex (cadr x) nil nil 'mparen rop))	;; summand
> ---
>> 	;; gotta be one of those above
>> 	;; 4th arg of tex is changed from mparen to (caar x)
>> 	;; to reflect the operator preceedance correctly.
>> 	;; This change improves the how to put paren.
>> 	(s1 (tex (cadr x) nil nil (caar x) rop))	;; summand
> 672c675,678
> < 	(s1 (tex (cadr x) nil nil 'mparen rop))	;; summand
> ---
>> 	;; 4th arg of tex is changed from mparen to (caar x)
>> 	;; to reflect the operator preceedance correctly.
>> 	;; This change improves the how to put paren.
>> 	(s1 (tex (cadr x) nil nil (caar x) rop))	;; summand
> 814c820,821
> <     (setf (get a 'tex-rbp) 130)))
> ---
>>    (setf (get a 'tex-rbp) 119)))
>> ;;    (setf (get a 'tex-rbp) 130)))
>
>
> Yasuaki Honda
> Chiba, Japan
>
> http://members3.jcom.home.ne.jp/imaxima/
>
> mailto:imaxima at mac.com
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima