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

MathGroup Archive 2010

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

Search the Archive

Re: Output x^-1

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113578] Re: Output x^-1
  • From: Simon <simonjtyler at gmail.com>
  • Date: Wed, 3 Nov 2010 02:55:31 -0500 (EST)
  • References: <201011011000.FAA20473@smc.vnet.net> <iaonns$jmr$1@smc.vnet.net>

You have to overwrite the default display behaviour (remember that
internally it is represented as Power[x,-1])

So try something like

Unprotect[Power]; Power /: MakeBoxes[Power[x_, -1], form_] :=
 With[{xbox = ToBoxes[x], ibox = ToBoxes[i]},
  SuperscriptBox[xbox, RowBox[{"-", "1"}]]]
Protect[Power];

or more generally

Unprotect[Power];
Power /: MakeBoxes[Power[x_, i_?Negative], form_] :=
  With[{xbox = ToBoxes[x], ibox = ToBoxes[i]},
  SuperscriptBox[xbox, ibox]]
Protect[Power];

You can clear the user defined definitions for Power using
Unprotect[Power]; Clear[Power]; Protect[Power];

Simon

On Nov 2, 9:04 pm, "Dave Snead" <dsne... at charter.net> wrote:
> Hi,
>
> Is there a way to have Mathematica maintain negative exponents on output?
>
> It automatically converts x^-1 to 1/x.
> I want x^-1 to output as x^-1.
>
> Thanks,
> Dave Snead


  • Prev by Date: Positive amd PositiveDefiniteQ
  • Next by Date: Re: Assertions in Mathematica?
  • Previous by thread: Output x^-1
  • Next by thread: Re: Balance point of a solid