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

*To*: mathgroup at smc.vnet.net*Subject*: [mg110735] Re: how to tell Mathematica to display x^-1 as x^-1 and not as 1/x*From*: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>*Date*: Sun, 4 Jul 2010 03:08:34 -0400 (EDT)*References*: <i0n9t5$hr6$1@smc.vnet.net>

Hi Nasser, I think the construction below should work. I don't have much experience with this, but I couldn't find any side effect. Unprotect[Power]; Power /: MakeBoxes[Power[x_, y_], StandardForm] := RowBox[{MakeBoxes[x, StandardForm], "^", MakeBoxes[y, StandardForm]}] Protect[Power]; Cheers -- Sjoerd On Jul 3, 2:19 pm, "Nasser M. Abbasi" <n... at 12000.org> wrote: > Hello; > > When I type > > x^-1 > > Mathematica replies > > 1/x > > Is there a way to tell Mathematica to *display* terms with negative > powers as x^-n and not as 1/x^n ? (i.e keep the term just like it > would appear on paper). > > Another example, suppose I type > > expr = a*x^-2 + b *x^-1 + > > The reason I want to do this, is just for display purposes. When I print > the expression on the screen, I'd like it to look like x^-1 and not like > 1/x (to better match how the expression look like in the textbook) > > I am trying to avoid having to convert everything to a string, and force > the form to the way I want. I tried Hold functions, and > TraditionalForm, but can't get it to print as I want. > > I am hoping there is an easy trick to do this? > > thanks > --Nasser