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

Am 03.07.2010 14:19, schrieb Nasser M. Abbasi:
> 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?

for this special case you could use the following:

expr /. Power[x, n_?Negative] :> Row[{x, "^", n}]

it should be fairly easy to adopt to other or more general cases.



  • Prev by Date: Re: precedence for ReplaceAll?
  • Next by Date: Re: How to solve
  • Previous by thread: Re: how to tell Mathematica to display x^-1 as x^-1 and not as 1/x
  • Next by thread: Display/manipulating numeric values inside a DynamicModule[]