Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 !

share|improve this question
    
Thank you @Sektor for reformatting ! –  Mark May 11 at 11:41
    
You are welcome ! If you are still experiencing troubles in the future, please, refer to the help centre for code formatting practices :) –  Sektor May 11 at 11:54

1 Answer 1

up vote 0 down vote accepted

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_"}]]]]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.