> From: Martin Kraska <kraska at fh-brandenburg.de>
> Date: Tue, 22 Oct 2013 22:16:13 +0200
>
> Hello,
>
> we are on the way to implement a Maxima plugin for the Mathcad-like free,
> but closed source math program SMath Studio.
>
> http://en.smath.info/forum/yaf_postst2078_Maxima-Plugin.aspx
> http://en.smath.info/forum/yaf_postst2086_Maxima.aspx
>
> The interface is in early alpha state and we are just beginners in Maxima.
> We hope to reach some day a level of maturity, justifying our interface tob
> e listed as software using maxima on the maxima homepage.
>
> We encountered a problem with expressions containing exponents which start
> with unary minus, just like
>
> e^-c/b
>
> in Maxima, this is equivalent to (e^(-c))/b, in SMath Studio, this is
> understood as e^(-c/b), i.e. something entirely different. There are similar
> cases like
>
> e^-cos(x)/b or e^-(x+y)/b ,
>
> see the problem example in
> http://en.smath.info/forum/yaf_postsm11340_Maxima-Plugin.aspx#post11340
>
> The root of the problems is the unusual low priority level of unary minus in
> SMath Studio.
>
> So far Maxima output scanning is not very sophisticated, just some
> replacements are made. We may have overseen an option to avoid the problem
> by proper output formatting. The ideal string would be
>
> e^{-c}/b
>
> (curly braces not being displayed in formatted SMath output)
>
> Is there a way to ask Maxima to include a bracket level in the output? An
> option would be to use tex output, where we have these brackets but that
> would require us to write a tex input parser for SMath...
>
> Any hints welcome.
>
> Best regards, Martin Kraska
There is a discussion of a related topic here:
http://www.math.utexas.edu/pipermail/maxima/2013/033188.html
My guess is that you could provide a slightly patched version of the
current 1d printer, and hook your custom printer in with the hook
discussed in that thread.
-----
Here is an alternative suggestion: define ^- as an infix operator in
Maxima with the same binding properties as in SMath.
(%i1) :lisp (list (get '$- 'lbp) (get '$- 'rbp))
(100 134)
(%i1) :lisp (list (get '$^ 'lbp) (get '$^ 'rbp))
(140 139)
Define ^- to have the same lbp as ^ and a low rbp so it globs to the right.
(%i1) infix("^-",140,50);
(%o1) "^-"
Define the operator to do what it should:
(%i2) "^-"(x,y) := x^ -y;
(%o2) (x ^- y):=x^-y
I think this is the behaviour you want:
(%i3) e^-c/d;
(%o3) 1/e^(c/d)
But you get the standard behaviour with a space:
(%i4) e^ -c/d;
(%o4) 1/(d*e^c)
And the non-intuitive behaviour without explicit brackets:
(%i6) e^-c/d + 1;
(%o6) e^(-c/d-1)
(%i7) (e^-c/d) + 1;
(%o7) 1/e^(c/d)+1
(%i8) e^(-c/d) + 1;
(%o8) 1/e^(c/d)+1
Leo