       Re: polynomial long division using Series[] and changing

• To: mathgroup at smc.vnet.net
• Subject: [mg112395] Re: polynomial long division using Series[] and changing
• From: Daniel Lichtblau <danl at wolfram.com>
• Date: Tue, 14 Sep 2010 05:12:47 -0400 (EDT)

```Nasser M. Abbasi wrote:
> Mathematica experts:
>
> I need a way to tell Mathematica to reverse the default ordering it uses
> for polynomial.
>
> The problem:
>
> I have 2 uni-variants polynomials num(z) and den(z), I can do the
> polynomial num(z)/den(z) long division using the Series command
>
> Series[num/den,{z,0,n}]
>
> Where n is the maximum number of terms I want to see in the long
> division. This is a small example
>
> ---------------
> num = 2 + z;
> den = z^2 + 2*z + 1;
> Normal[Series[num/den, {z, 0, 4}]]
>
> 2 - 3*z + 4*z^2 - 5*z^3 + 6*z^4
> ----------------
>
> But due to Mathematica default ordering of polynomial, which is from low
> to high degree, the above is long division done as follows, when done by
> hand:
>
>                     +----------
>       1+ 2*z + z^2  | 2 + z
>      ---------------+
>
> What I want is to do the long division as follows
>
>                     +----------
>       z^2 + 2*z + 1 | z + 2
>      ---------------+
>
> Which, when done by hand, would result in : z^-1 - z^-3 + 2 z^-4 +....
>
> The reason, is that I am using long division to find the inverse Z
> transform of H(z) = num(z)/den(z), and this is a causal discrete system,
> hence I need the result of the long division to come out in negative
> powers of z.
>
> Once the result comes out in negative powers of z, then I can read the
> impulse response h(n) from the corresponding coefficients of z's.
>
> Notice that Z transform is H(z)= Sum[ h(n) * z^(-n) ,{n,0,Infinity}].
>
> So, I need the long division to happen as in the second form above.
>
> i.e. I need the ordering of the polynomials to be from large degree to
> low degree (reverse what the default is).
>
> I did not know how to tell Mathematica Series command to do the division
> num/den using this ordering.
>
> I read this
>
> http://reference.wolfram.com/mathematica/tutorial/PolynomialOrderings.html
>
> But it is hard for me  to understand how to use the above information in
> the context of what I am trying to do.
>
> Is there any easy way to change this ordering so that Series[] will
> return the answer that I wanted? Is there Some option or may be some
> global setting I need to set?
>
> thanks
> --Nasser
>

Easiest is to expand at infinity.

In:= Normal[Series[num/den, {z, Infinity,4}]]
Out//InputForm= 2/z^4 - z^(-3) + z^(-1)

Alternatively, could expand at zero but change z to 1/z, then change
back when finished.

In:= Normal[Series[num/den/.z->1/z, {z, 0, 4}]]/.z->1/z
Out//InputForm= 2/z^4 - z^(-3) + z^(-1)

Another route would be to homogenize in a new variable, call it w. Then
do a Series expansion in w. Here are the homogenized forms in this example.

num2 = 2*w+z;
den2 = z^2 + 2*z*w+w^2;

Now expand at w=0, then replace with w->1. I realize that seems weird.
But it works for the task at hand (thought might give fewer terms, or
more, than what you get from same order expansions using methods above).

In:= Normal[Series[num2/den2, {w,0,3}]]/.w->1
Out//InputForm= 2/z^4 - z^(-3) + z^(-1)

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: polynomial long division using Series[] and changing polynomial
• Next by Date: Re: an issue of consistency
• Previous by thread: Re: polynomial long division using Series[] and changing
• Next by thread: get a table of coordinates from an image of a graph