3
$\begingroup$

Is there a way to stop Mathematica from turning every negative power $z^{-n}$ into $1/z^n$ in TraditionalForm? I'd like to get this:

Negative power

but 1/(1 - p z^-1) // TraditionalForm gives me this:

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Have you tried 1/(1 - p z^HoldForm[-1]) ? $\endgroup$ – LouisB Jun 1 '17 at 20:51
  • $\begingroup$ That never occurred to me. Thanks! $\endgroup$ – Rodney Price Jun 1 '17 at 21:32
5
$\begingroup$

It should be noted that these forms are interchangeable in Mathematica, by which I mean that there is both interconversion and that display does not match the internal form.

Power[x, -1] is displayed as 1/x, and 1/x is read as Times[1, Power[x, -1]].

a/b

% // FullForm
a/b

Times[a, Power[b, -1]]

So you cannot automatically have 1/(1 - p z^-1) displayed as ] without rules to distinguish the main reciprocal from the lower one.

You can prevent formatting by making -1 a non-number using Defer or HoldForm as LouisB recommended in a comment:

1/(1 - p z^Defer[-1]) // TraditionalForm

enter image description here

I am not sure if this kind of manual intervention is what you are seeking.

For the particular case this formatting rule on MakeBoxes gets the job done but it may affect, or fail to affect, the display of other expressions in a way you do not want.

MakeBoxes[a_*x_^-1, TraditionalForm] := 
  ToBoxes[a*Superscript[x, -1], TraditionalForm]

Now:

1/(1 - p z^-1) // TraditionalForm

enter image description here

$\endgroup$
  • $\begingroup$ If I change the pattern to a_*z^-n_ the MakeBoxes function does just what I need. Thank you. $\endgroup$ – Rodney Price Jun 1 '17 at 21:39
  • $\begingroup$ @Rodney In that case I'm glad I could help. :-) $\endgroup$ – Mr.Wizard Jun 1 '17 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.