It should not be necessary to rebuild Maxima unless you are changing to a
new version of Lisp. Almost any change to the maxima code itself can be
done by loading the patch into a system, either manually, or via some maxima
init.lisp file.
The spec for form-mtimes was unspecified; apparently it takes input either
of the form ((mtimes <flags>) arg1 arg2 arg3 ...) but also
Without the mtimes. i.e. ( arg1 arg2 arg3 ...) so I have to check for the
mtimes. The program, given below, fixes the bug you noted. Thanks.
RJF
(in-package :maxima)
(defun form-mtimes (form)
(cond ((null (cdr form)) '((mtimes)))
((and (mtimesp form) ;; sometimes form-mtimes gets
;;just list without(( mtimes)..)
(member 'factored(cdar form)))
; if factored like 2 3^2, put in dots.
(nformat (cons '(mnctimes) (cdr form))))
((equal -1 (cadr form)) (list '(mminus) (form-mtimes (cdr form))))
(t (prog (num den minus flag)
(do ((l (cdr form) (cdr l)) (dummy)) ((null l))
(setq dummy (nformat (car l)))
(cond ((atom dummy) (setq num (cons dummy num)))
((eq 'mminus (caar dummy))
(setq minus (not minus) l (append dummy (cdr l))))
((or (eq 'mquotient (caar dummy))
(and (not $pfeformat) (eq 'rat (caar dummy))))
(cond ((not (equal 1 (cadr dummy)))
(setq num (cons (cadr dummy) num))))
(setq den (cons (caddr dummy) den)))
(t (setq num (cons dummy num)))))
(setq num (cond ((null num) 1)
((null (cdr num)) (car num))
(t (cons '(mtimes) (nreverse num))))
den (cond ((null den) (setq flag t) nil)
((null (cdr den)) (car den))
(t (cons '(mtimes) (nreverse den)))))
(if (not flag) (setq num (list '(mquotient) num den)))
(return (if minus (list '(mminus) num) num))))))
-----Original Message-----
From: maxima-admin at math.utexas.edu [mailto:maxima-admin at math.utexas.edu] On
Behalf Of Matthew Sarnoff
Sent: Friday, July 21, 2006 8:06 AM
To: Richard Fateman
Cc: maxima at math.utexas.edu
Subject: Re: [Maxima] tex() and multiplication
I rebuilt Maxima with your fix, and it made factor() work properly,
but it has some unfortunate side effects. I tried to evaluate
diff(1/x,x)
and got the following:
Maxima encountered a Lisp error:
Type-error in KERNEL::OBJECT-NOT-LIST-ERROR-HANDLER: -1 is not of
type LIST
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
I restored the original version of nforma.lisp, recompiled, and I no
longer get the error. No idea what might have caused that...
-matt
On Jul 20, 2006, at 5:26 PM, Richard Fateman wrote:
> 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
>
>
>
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima