MathGroup Archive 2010

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

Search the Archive

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


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



  • Prev by Date: Re: How to solve
  • Next by Date: Re: non rectangular crop
  • Previous by thread: how to tell Mathematica to display x^-1 as x^-1 and not as 1/x
  • Next by thread: Re: how to tell Mathematica to display x^-1 as x^-1 and not as 1/x