Message Boards Message Boards

how to get coefficient list from a polynomial with positive and negative powers?

Posted 3 days ago

Hi,

This is a math problem. Solving an equation

How to collect y power coefficients and then solve as a device, both positive and negative power? Can you help me? This is example enter image description here

POSTED BY: Sami Heidari
3 Replies

Shift the powers to make a polynomial; store the max degree in the data structure (somewhat like RealDigits)l

u = b/y^3 + c + a y^2;

coeffs =(* {coefficient list, max degree}*)
 {CoefficientList[u/y^Exponent[Series[u, y -> 0], y], y], 
  Exponent[u, y]}

(*  {{b, 0, 0, c, 0, a}, 2}  *)

Reconstruct the expression:

First[coeffs] . (y^Range[Last[coeffs] - Length@First[coeffs] + 1, Last[coeffs]])

(*  c + b/y^3 + a y^2  *)
POSTED BY: Michael Rogers
Posted 18 hours ago

You didn't understand what I meant. I want, for example, the same function u that you considered to give me a list as follows:

{b, 0, 0, c, 0, a}

But it goes like this:

In[154]:= u = b/y^3 + c + a y^2;

coeffs =({coefficient list,max degree}){CoefficientList[ u/y^Exponent[Series[u, y -> 0], y], y], Exponent[u, y]}

Out[155]= {{c + b/y^3, 0, a}, 2}

POSTED BY: Sami Heidari

I don't get the output you showed. I get the output I showed.

Your unformatted code is missing the *s from the comment, but I fixed that when I tested. As I said, I got what I showed, not what you showed in your reply.

This seems obvious: If you don't want the exponent, leave it off and just use the CoefficientList[..] part of the code without the braces. So if you want something else, please explain.

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract