MathGroup Archive 2004

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

Search the Archive

Re: how do I display "Power[z,-1]" in an exponetial form?


dumstuck at gmx.ch (dumstuck at gmx.ch) wrote in message news:<ci8mqm$bt3$1 at smc.vnet.net>...
> In the field of DSP engineering we like keeping the expression "1/z"
> in the form of "z minus one", namly in a exponential form. Both the "z
> minus one" and "1/z" has the same "FullForm", namely "Power[z,-1]".
> But they both get displayed in a fractional form. how could I change
> that way of diplaying "Power[z,-1]"?

You can use MakeBoxes:

MakeBoxes[k_. * x_ ^ n_, form_] := Module[
  {kbox, xbox, nbox, powbox},
  kbox = MakeBoxes[k, form];
  xbox = MakeBoxes[x, form];
  nbox = MakeBoxes[n, form];
  If[Head @ xbox =!= String,
    xbox = RowBox[{"(", xbox, ")"}]
  ];
  powbox = SuperscriptBox[xbox, nbox];
  Switch[kbox,
    "1", powbox,
    RowBox[{"-", "1"}], RowBox[{"-", powbox}],
    _, RowBox[{kbox, " ", powbox}]
]]


Evaluate -1/(a+Sqrt[b])-1/a^2 in the front end to see how the output
will be formatted. It will work with StandardForm and TraditionalForm.
There is no need for a 'reverse' MakeExpression definition, because
the output can be correctly interpreted by Mathematica.
FormatValues[MakeBoxes]={} will clear this definition.

Maxim Rytin
m.r at inbox.ru


  • Prev by Date: Re: Re: Forcing a Derivative
  • Next by Date: Re: Bilinear Transforms
  • Previous by thread: Re: how do I display "Power[z,-1]" in an exponetial form?
  • Next by thread: Re: how do I display "Power[z,-1]" in an exponetial form?