Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110738] how to tell Mathematica to display x^-1 as x^-1 and not as 1/x
  • From: Carlos CÃsar de AraÃjo <cca at gregosetroianos.mat.br>
  • Date: Sun, 4 Jul 2010 03:09:07 -0400 (EDT)
  • Organization: Gregos e Troianos Educacional

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


  • Prev by Date: Re: plot
  • Next by Date: Re: precedence for ReplaceAll?
  • Previous by thread: Re: Is it possible to query current plot range values (or have
  • Next by thread: Re: how to tell Mathematica to display x^-1 as x^-1 and not as 1/x