3
$\begingroup$

I want Mathematica to display negative exponents always as fractions. I already tried:

Needs["Notation`"] (* Notation[1/a_^b_ <==> a_^-b_] *) Notation[ ParsedBoxWrapper[RowBox[{"1", "/", RowBox[{"a_", "^", "b_"}]}]] ⟺ ParsedBoxWrapper[RowBox[{"a_", "^", RowBox[{"-", "b_"}]}]]] 

While I do have

x^-z 
1/x^z 

the following doesn't work:

x^-(2z) 
x^-2z 

Some hints ? Thank you very much !

$\endgroup$
2
  • $\begingroup$ Thank you @Sektor for reformatting ! $\endgroup$ Commented May 11, 2014 at 11:41
  • $\begingroup$ You are welcome ! If you are still experiencing troubles in the future, please, refer to the help centre for code formatting practices :) $\endgroup$ Commented May 11, 2014 at 11:54

1 Answer 1

0
$\begingroup$

I found a working solution for my case. It still uses the Notation Package and makes use of PatternWrappers:

Here is the Code:

Needs["Notation`"] (*Notation[1/Simplify[a_^(-b_ c_)] <==> a_^TemplateBox[b_?Negative] c_]*) (*Notation[(a_^d_)/Simplify[a_^(-b_ c_)] <==> a_^TemplateBox[b_?Negative] c_+d_]*) ClearNotations[] Notation[ParsedBoxWrapper[ FractionBox["1", SuperscriptBox["", TemplateBox[{ RowBox[{"Simplify", "[", SuperscriptBox["a_", RowBox[{ RowBox[{"-", "b_"}], " ", "c_"}]], "]"}]}, "NotationPatternTag"]]]] \[DoubleLongLeftArrow] ParsedBoxWrapper[ SuperscriptBox["a_", RowBox[{ TemplateBox[{ RowBox[{"b_", "?", "Negative"}]}, "NotationPatternTag"], " ", "c_"}]]]] Notation[ParsedBoxWrapper[ FractionBox[ SuperscriptBox["a_", "d_"], TemplateBox[{ RowBox[{"Simplify", "[", SuperscriptBox["a_", RowBox[{ RowBox[{"-", "b_"}], " ", "c_"}]], "]"}]}, "NotationPatternTag"]]] \[DoubleLongLeftArrow] ParsedBoxWrapper[ SuperscriptBox["a_", RowBox[{ RowBox[{ TemplateBox[{ RowBox[{"b_", "?", "Negative"}]}, "NotationPatternTag"], " ", "c_"}], "+", "d_"}]]]] 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.