tex() and multiplication



OK guys, I think I have a pretty good fix.

In the file nforma.lisp
There is a function form-times.  Add two lines to it.


(defun form-mtimes (form)
  (cond ((null (cdr form)) '((mtimes)))

	((member 'factored(cdar form)) ; if factored, like 2 3^2, put in
dots.
	 (nformat (cons '(mnctimes) (cdr form)))) ;rest of fix. RJF
20-July-06

	((equal -1 (cadr form)) (list '(mminus) (form-mtimes (cdr form))))
.....



Not only does this make the tex work, but it makes the ordinary display work
better.  That is,
 Factor(6)   comes out as 2 . 3     instead of 2 3
Factor (x^2-1) comes out as (x-1) . (x+1)

And tex works the same way.

The semantics are not changed.  Just the output formatting, so the commands
"part", display and Tex -- the only ones that works on the output of the
nformat program -- change.   Part will now think that part(factor(120),0)
is ".".  Since part should not be used (try inpart instead), maybe this is
acceptable. Inpart(factor(120,0) will be "*".

Some results from factor look rather different, e.g.  factor(1/6) changes
from 1/(2 3) to (1/2).(1/3).

Also 1/factor(1/120)  comes out as  3 5 8,  but that's the same as before.
The bug fix would be to change that to 120 by fixing the simplifier, I
think.

The whole fixed function is in
http://www.cs.berkeley.edu/~fateman/temp/form-times.lisp

Move it to, say c:/temp on your machine. In maxima, type
load("c:/temp/form-times.lisp");

As for making something different for the display of derivatives, look at
the code around derivabbrev.  Most people who have looked at this closely
usually decide that math notation is defective here.

RJF




-----Original Message-----
From: maxima-admin at math.utexas.edu [mailto:maxima-admin at math.utexas.edu] On
Behalf Of Matthew Sarnoff
Sent: Thursday, July 20, 2006 1:37 PM
To: Chris Sangwin
Cc: maxima at math.utexas.edu
Subject: tex() and multiplication

Chris: (defprop mtimes "\\cdot " texsym) will put a dot between _any_  
two expressions that are multiplied together. This makes expressions  
like "2*3" look fine, but "2*x" and "'diff(y,x)" look strange.

Due to the many forms that the multiplication operator can take, I  
think that the behavior of times should be extended in the following  
way:

1. If the two expressions on either side of the operator are literal  
numbers (i.e. numberp returns true), then "\\cdot " should be used.
2. If not, "\\," should be used, except:
3. In noun-forms of derivatives, no space at all (or very small  
space) should be used in the denominator between the "d"/"\partial"  
and the "x" variable. The current behavior (separate the two with the  
"mtimes" symbol) looks a bit unclean.

Also, speaking of derivatives, I think that when formatting 'diff 
(y,x), the "y" should be placed in the numerator if it is an atom.  
That way, 'diff(y,x) would render nicely as

dy
--
dx

instead of

d
-- y
dx

I've found the functions in mactex.lisp (tex-nary and tex-d) that  
need to be changed to accomodate this behavior, but I don't have  
enough Lisp experience to implement it. Thought I'd suggest it, though.

-matt

_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima