开发者

how to solve for the unknowns given two equating polynomials in mathematica

I have, for example, the following polynomials to be equated, and I need to determine the unknowns c1, c2, c3, respectively. How can I do this automatically in mma, especially when there are many terms involved?

x+2*x^3+4*x^5==(c1+c2)*(x+2*c2*x^3)+(4-c1)*c3*x^5

Many thanks.

Edit: ideally, I want to equate the coefficients of left and right for the terms with equa开发者_JAVA技巧l exponents in x. Then solve this system of equations.


If this has to be true for all x, you could use SolveAlways (not tested)

SolveAlways[x+2*x^3+4*x^5==(c1+c2)*(x+2*c2*x^3)+(4-c1)*c3*x^5, x]


Try:

p1 = x + 2*x^3 + 4*x^5;
p2 = (c1 + c2)*(x + 2*c2*x^3) + (4 - c1)*c3*x^5;

Solve[CoefficientList[p2, x] == CoefficientList[p1, x], {c1, c2, c3}]  

Out

 {{c1 -> 0, c2 -> 1, c3 -> 1}}


This should do what you want even in more complicated situations.

eq = x + 2*x^3 + 4*x^5 == (c1 + c2)*(x + 2*c2*x^3) + (4 - c1)*c3*x^5;
list = CoefficientList[eq /. Equal[k__, l__] -> Plus[k, -l], x];
vars = Variables@list;
Solve[list == Table[0, {i, First@Dimensions@list}], vars]

Out[1] := {{c1 -> 0, c2 -> 1, c3 -> 1}}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜