MATLAB: Is it possible to display negative integer exponentials in MATLAB’s MuPAD Symbolic Notebook

laurentpolynomialSymbolic Math Toolbox

I would like get MuPAD to give me back polynomials with negative integer exponentials instead of displaying them in the rational form. For example, the following code in the MuPAD
% THIS CODE SHOULD BE WRITTEN IN THE MUPAD NOTEBOOK
[ f := (b0 * z^(2) + b1 * z^(1) + b2) / z^(2)
gives me:
[ 1/z^2*(b0*z^2 + b1*z + b2)
I would like to "simplify" this to
[ b0 + b1 * z^(-1) + b2 * z^(-2)
This would mainly be useful for me when creating and displaying a Laurent Polynomial.

Best Answer

The ability to directly display negative exponents is not available in MuPAD .
A workaround would be to place all the exponents into a domain that hides the negative signs from the output code for a while. As an example, try running the following code in the MuPAD Notebook:
domain expo
new := e -> new(dom, e);
print := e -> extop(e, 1);
end:
Pref::output(ex -> misc::maprec(ex,
{"_power"} = (ex -> subsop(ex, 2 = expo(op(ex, 2)), Unsimplified)))):
f := (b0 * z^(2) + b1 * z^(1) + b2) / z^(2);expand(f)
Note that this has the side effect of breaking the display of all fractions other than rational numbers. However, one can create a domain for the Laurent series that does something like the example shown for the exponents of the series variable and only there. That would ensure that the order of the terms is fixed and that the z factor is always the last in the product.
Related Question