How to avoid ^- in maxima output? (Leo Butler)



>   From: Martin Kraska <kraska at fh-brandenburg.de>
>   CC: <maxima at math.utexas.edu>
>   Date: Thu, 24 Oct 2013 18:05:04 +0200
>
>   Leo,
>
>   thanks a lot for the great help.
>
>   I did not examine the code yet but I see that this might be the solution of
>   the given problem and I am glad to see that such problems can be handled on
>   the Maxima side. We would like to avoid any modification of existing Maxima
>   installations and rather load the scripts from our plugin directory. I guess
>   that the search path for maxima can be extended accordingly.
>
>   Best regards, Martin


Martin, sorry for the delay in replying, my outbound email server has
been down for a while.

I don't know if your project has found the code that I wrote
useful. If so, and you wish to use it to provide a plugin to Maxima,
then there is the issue of distribution. I do not know if your
licensing is compatible with GPLv2. If it is, then please distribute
the code with your plugins. If it is not *or* you are unsure (and I
suspect this is the case), then the code can be added to Maxima under
the share/contrib directory where it will be distributed under GPLv2.

Regards,
Leo

>
>   > -----Urspr?ngliche Nachricht-----
>   > Von: Leo Butler [mailto:l_butler at users.sourceforge.net]
>   > Gesendet: Donnerstag, 24. Oktober 2013 16:48
>   > An: Martin Kraska
>   > Cc: maxima at math.utexas.edu
>   > Betreff: Re: [Maxima] How to avoid ^- in maxima output? (Leo Butler)
>   > 
>   > >   From: Martin Kraska <kraska at fh-brandenburg.de>
>   > >   Date: Thu, 24 Oct 2013 01:09:02 +0200
>   > >
>   > >   Leo, thanks for the response ( and Robert, for your's as well).
>   > >
>   > >   Other examples are
>   > >
>   > >   "e^-cos(x)/b", misunderstood as e^{-cos(x)/b},
>   > >   "e^-c/b" , misunderstood as  e^{-c/b}
>   > >
>   > >   1d versions which would be understood correctly, are:
>   > >   "e^(-cos(x))/b"
>   > >   "e^(-c)/b"
>   > >
>   > >   Thus, how can Maxima be forced to bracket the unary minus operator in
>   1d
>   > >   output?
>   > 
>   > Ok, I do see what you want. My suggestion is basically what RJF and Robert
>   > were hinting at. What you can do is use Maxima's ability to apply
>   > transformation rules to expressions to re-write the expression before it
>   is
>   > displayed. Here is what I mean:
>   > 
>   > (%i10)  (to_mx_display(), kill(all), load("smath.mac"))$
>   > 
>   > (%i1) [e^-4, %e^-t/d, %e^-cos(x)/y];
>   > (%o1) [1/e^4,%e^-t/d,%e^-cos(x)/y]
>   > 
>   > (%i2) to_sm_display();
>   > (%s2) %s                                  <-- change outchar for different
>   display mode
>   > 
>   > (%i3) [e^-4, %e^-t/d, %e^-cos(x)/y];
>   > (%s3) [e^{-4},%e^{-t}/d,%e^{-cos(x)}/y]   <-- desired output
>   > 
>   > (%i4) to_mx_display();
>   > (%o4) %o                                  <-- revert to maxima's standard
>   1d display
>   > 
>   > (%i5) %s3;
>   > (%o5) [1/e^4,%e^-t/d,%e^-cos(x)/y]        <-- the expr in %s3 is valid
>   maxima
>   > code
>   > 
>   > where
>   > 
>   > smath.mac:
>   > /* -*- Mode: maxima; Package: MAXIMA -*- */
>   > /*
>   > ;; Copyright Leo Butler (leo.butler at member.fsf.org) 2013 ;; Released under
>   the
>   > terms of GPLv2 */
>   > 
>   > matchdeclare([sm_x],true,sm_y,lambda([e],if is(numberp(e) and e<0 and
>   e#-1)
>   > or is(not(atom(e)) and op(e)="-") then true else false));
>   > defrule(sm_exp_to_power,sm_x^sm_y,sm_x^{sm_y});
>   > sm_rules:['sm_exp_to_power];
>   > 
>   > load("smath.lisp")$
>   > 
>   > /* end of smath.mac */
>   > 
>   > 
>   > smath.lisp:
>   > ;; -*- mode: lisp -*-
>   > ;; Copyright Leo Butler (leo.butler at member.fsf.org) 2013 ;; Released under
>   the
>   > terms of GPLv2
>   > 
>   > (in-package :maxima)
>   > 
>   > (defvar *displa* (symbol-function 'displa)) (defvar *maxima-outchar*
>   $outchar)
>   > (defvar *smath-outchar* '$%s) (defvar $sm_rules)
>   > 
>   > (defun $smath_displa (form &optional (sm-rules $sm_rules))
>   >   "Display FORM by APPLY1-ing the rules in SM-RULES to the EXPR in FORM."
>   >   (declare (special $sm_rules *alt-display1d*))
>   >   (let ((rules (cdr sm-rules))
>   >         (*alt-display1d* nil)
>   >         (expr (third form)))
>   >     (funcall *displa*
>   >              (list (first form) (second form)
>   >                    (dolist (rule rules expr)
>   >                      (setf expr (mfuncall '$apply1 expr rule)))))))
>   > 
>   > (defun $to_sm_display ()
>   >   "Set-up Maxima to use SMATH_DISPLA to display output."
>   >   (declare (special *alt-display1d* $outchar *smath-outchar*))
>   >   (setf *alt-display1d* (symbol-function '$smath_displa))
>   >   (setf $outchar *smath-outchar*))
>   > 
>   > (defun $to_mx_display ()
>   >   "Return Maxima to use standard DISPLA for 1d output."
>   >   (declare (special *alt-display1d* $outchar *maxima-outchar*))
>   >   (setf *alt-display1d* nil)
>   >   (setf $outchar *maxima-outchar*))
>   > 
>   > 
>   > ; end of smath.lisp
>   > 
>   > Leo
>