On 10/14/07, Robert Marik <marik at mendelu.cz> wrote:
> when exporting to TeX, cos(x)*y is printed as \cos x\,y and my students
> could read this at cos(x*y).
>
> Is here any variable which changes this behavior, or any possibility how
> to keep the parentheses around x? I mean that tex(cos(x)*y) should give
> \cos (x)\,y instead of \cos x\,y
It is easy enough to adjust the placement of parentheses,
but a little tricky to get a reasonable output in all cases.
For TeX output, Maxima treats sin, cos, etc as prefix
operators with a precedence greater than multiplication.
So cos xy has to mean (cos x)*y; cos(x*y) is output as cos(xy).
For TeX output, we could change the precedence of
sin, cos, etc to be less than that of multiplication. Then
cos xy has to mean cos(x*y), and cos(x)*y is output as (cos x) y.
Robert, if you want to go down that road, try this:
:lisp (mapcar #'(lambda (x) (setf (get x 'tex-rbp) 110)) '(%sin %cos %tan))
Instead of generating cos xy for some input or the other,
we could avoid the ambiguity by writing some custom code to
process sin, cos, etc for TeX output, which would put in
extra parentheses in some cases.
> I solve this problem when working on a simple system which solves ODE's
> and shows intermediate steps, the outputs look like
> http://old.mendelu.cz/~marik/maw/ode_offline/ and the form to submit an
> equation is http://old.mendelu.cz/~marik/maw/#ode (covers linear and
> separeted equations)
Looks like an interesting application. Keep up the good work.
best
Robert Dodier