Re: how to tell Mathematica to display x^-1 as x^-1 and not as 1/x
- To: mathgroup at smc.vnet.net
- Subject: [mg110737] Re: how to tell Mathematica to display x^-1 as x^-1 and not as 1/x
- From: telefunkenvf14 <rgorka at gmail.com>
- Date: Sun, 4 Jul 2010 03:08:56 -0400 (EDT)
- References: <i0n9t5$hr6$1@smc.vnet.net>
On Jul 3, 7:19 am, "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
I've always found this behavior perplexing as well. A great example of
something that can drive you nuts! (Mathematically trivial time-
waster). Here's a hacky workaround that you probably won't like...
(First, note that this doesn't work...)
In[1]:= x^a//HoldForm
%/.a->-1
Out[1]= x^a
Out[2]= 1/x
(But this does...)
In[3]:= x^-a//HoldForm
%/.a->1
Out[3]= x^-a
Out[4]= x^-1
There has to be an easier way---I do seem to recall reading about this
issue before, but couldn't find it in the documentation.
-RG