# Collect all terms containing the same powers of a function in a polynomial

I have a polynomial including powers of \[CapitalPhi][\[Xi]]

• I want to collect all terms containing the same powers of \[CapitalPhi][\[Xi]]

• Then, I want to equate the coefficients of the terms to $$0.$$ (It yields to the system of algebraic equations.)

• Finally, I want to solve the equation system including the unknowns Subscript[a, 0], Subscript[a, 1], Subscript[b, 1], r. (Other terms such as Subscript[\[Lambda], 1], Subscript[\[Lambda], 2] are parameters. They can be assigned to $$1$$)


POLY:=(r - p Subscript[\[Lambda], 1] +p^2 Subscript[\[Lambda], 2]) (Subscript[a, 0] + Subscript[b,
1]/\[CapitalPhi][\[Xi]] + Subscript[a, 1] \[CapitalPhi][\[Xi]]) +
Subscript[\[Lambda],
3] (Subscript[a, 0] + Subscript[b, 1]/\[CapitalPhi][\[Xi]] +
Subscript[a, 1] \[CapitalPhi][\[Xi]])^3 -
Subscript[\[Lambda],
2] (2 Subscript[a,
1] \[CapitalPhi][\[Xi]] (2 + \[CapitalPhi][\[Xi]]^2) +
Subscript[b,
1] (-((2 (2 + \[CapitalPhi][\[Xi]]^2))/\[CapitalPhi][\[Xi]]) + (
2 (2 + \[CapitalPhi][\[Xi]]^2)^2)/\[CapitalPhi][\[Xi]]^3));

CoefficientList[Expand[POLY], \[CapitalPhi][\[Xi]]^_]



Is SolveAlways what you need?

POLY = (r - p λ1 + p^2 λ2) (a0 + b1/Φ[ξ] + a1 Φ[ξ]) +
λ3 (a0 + b1/Φ[ξ] + a1 Φ[ξ])^3 -
λ2 (2 a1 Φ[ξ] (2 + Φ[ξ]^2) +
b1 (-((2 (2 + Φ[ξ]^2))/Φ[ξ]) + (2 (2 + Φ[ξ]^2)^2)/Φ[ξ]^3));

SolveAlways[POLY == 0, Φ[ξ]]
(*    {{a0 -> 0, a1 -> 0, b1 -> 0},
{r -> p λ1, λ2 -> 0, λ3 -> 0},
{r -> p λ1 - p^2 λ2 - a0^2 λ3, a1 -> 0, b1 -> 0},
{r -> p λ1 - p^2 λ2, a1 -> 0, b1 -> 0, λ3 -> 0},
{r -> p λ1 - a0^2 λ3, a1 -> 0, λ2 -> 0, b1 -> 0},
{r -> p λ1 - a0^2 λ3, b1 -> 0, λ2 -> 0, a1 -> 0},
{r -> p λ1 - a0^2 λ3, λ2 -> 0, a1 -> 0, b1 -> 0},
{r -> 1/2 (2 p λ1 - 2 a0^2 λ3 - a0^2 p^2 λ3),
a1 -> 0, λ2 -> (a0^2 λ3)/2, b1 -> 0},
{r -> 1/2 (2 p λ1 + 4 a1^2 λ3 - a1^2 p^2 λ3),
b1 -> 0, λ2 -> (a1^2 λ3)/2, a0 -> 0},
{r -> 1/8 (8 p λ1 + 4 b1^2 λ3 - b1^2 p^2 λ3),
a1 -> 0, λ2 -> (b1^2 λ3)/8, a0 -> 0},
{a0 -> 0, a1 -> -(b1/2),
r -> 1/8 (8 p λ1 + 16 b1^2 λ3 - b1^2 p^2 λ3),
λ2 -> (b1^2 λ3)/8},
{a0 -> 0, a1 -> b1/2,
r -> 1/8 (8 p λ1 - 8 b1^2 λ3 - b1^2 p^2 λ3),
λ2 -> (b1^2 λ3)/8}}                              *)


This generates equations you are trying to solve.

Series[POLY /. Φ[ξ] -> s, {s, 0, 8}] == 0 // LogicalExpand // FullSimplify


I leave the solution of these equations to you.

Notes:

• Change of variable to s is likely to make the algebra more reliable
• Series expansion generates the coefficients for s that I think you are asking for (no harm in asking for an unnecessarily high order of expansion)
• LogicalExpand turns these into a set of equations, one per term.
• Seriously, I'd avoid using subscripts in this sort of manipulation (e.g. use Subscript[λ, 3]->λ3 to replace them (and reverse this after you have the answer you want to present)