f



how to tell Mathematica to display x^-1 as x^-1 and not as 1/x

Nasser,

>Is there a way to tell Mathematica to 
>*display* terms with negative 
>powers as  x^-n  and not as 1/x^n ?


There are many things that you will have to consider, but here goes a
start:

MakeBoxes[Power[x_, y_?(NumberQ[#] && Negative[#] &)], 
  TraditionalForm] := 
 SuperscriptBox[MakeBoxes[x, TraditionalForm], 
  MakeBoxes[y, TraditionalForm]]

MakeBoxes[Times[c_, p : Power[x_, y_?(NumberQ[#] && Negative[#] &)]], 
  TraditionalForm] := If[OrderedQ[{c, p}],
  RowBox[{MakeBoxes[c, TraditionalForm], 
    MakeBoxes[p, TraditionalForm]}], 
  RowBox[{MakeBoxes[p, TraditionalForm], 
    MakeBoxes[c, TraditionalForm]}]]

There are other solutions (for example, TemplateBox, about which I posted
some information elsewhere).

Carlos César de Araújo
Gregos & Troianos Educacional
www.gregosetroianos.mat.br
Belo Horizonte, MG, Brasil
(31) 3283-1122

0
UTF
7/4/2010 7:09:23 AM
comp.soft-sys.math.mathematica 28821 articles. 0 followers. Follow

0 Replies
779 Views

Similar Articles

[PageSpeed] 40

Reply: