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
  • Subject: [mg113578] Re: Output x^-1
  • From: Simon <simonjtyler at>
  • Date: Wed, 3 Nov 2010 02:55:31 -0500 (EST)
  • References: <> <iaonns$jmr$>

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"}]]]

or more generally

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

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


On Nov 2, 9:04 pm, "Dave Snead" <dsne... at> 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