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
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 *)
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}
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.
I attached the code.
Another question?
“Why does func return the correct result, but func1 does not?”
I don’t understand what goes wrong in your code. I copied the notebook you posted and ran it. I got the following below, which is the same result as I obtained originally:
https://www.wolframcloud.com/obj/mroge02/Published/361378166
(For some reason, the “Add Notebook” does seem to add the notebook. So I just pasted a link.)