Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider the following code:

m = 4;
n = 3;
TraditionalForm[Sum[(-1)^(i + 1) * Binomial[n, i] * x^(m * i), {i, 0, n}]] == 
TraditionalForm[Collect[Sum[(-1)^(j + 1) * Binomial[n, j] * x^j, {j, 0, n}] *
 Sum[Subscript[a, i] * x^i, {i, 0, n * (m - 1)}], x]]


From this I would like to match the coefficients in each term in the two polynomials and thereby get n*m+1 equations and solve them for the n*(m-1)+1 a_i's.


After using bill s's answer, I get the following:

    Sum[(-1)^(i + 1)*Binomial[n, i]*x^(m*i), {i, 0, n}] - 
     Sum[(-1)^(j + 1)*Binomial[n, j]*x^j, {j, 0, n}]*
      Sum[a[i]*x^i, {i, 0, n*(m - 1)}]], x] == 0, 
 Table[a[i], {i, 0, n*(m - 1)}]]


Now, I would like to write out the equation but the following attempt fails:

Sum[a[i - n]*x^i, {i, n, n*m}]


Only the a[i]s are printed, not the values of the, which have been computed with the previous chunk of code.

share|improve this question
Svend, I see that recently you are doing a lot of editing of questions. That is fine, but please try not to edit questions that are likely to be closed down. I reviewed a few of your edits, and they are mostly quite minor: they unnecessarily bump up an otherwise low question and forces reviewers to deal with it. Please try to be more considerate when editing, and do not edit only to italicize the word Mathematica, etc.. If you want to raise your rep, try asking/answering questions, it is really not that hard :) – István Zachar Dec 13 '13 at 9:00
up vote 1 down vote accepted

Here is another way. Not too functional, but can be made to:

ClearAll[a, x];
m = 4;
n = 3;
vars = Table[Subscript[a, i], {i, 0, n*(m - 1)}];
lhs = Sum[(-1)^(i + 1)*Binomial[n, i]*x^(m*i), {i, 0, n}]
rhs = Sum[(-1)^(j + 1)*Binomial[n, j]*x^j, {j, 0, n}]*
  Sum[Subscript[a, i]*x^i, {i, 0, n*(m - 1)}];

Now build the eqs:

eqs = {};
c = CoefficientList[rhs, x];
d = CoefficientList[lhs, x];
Do[AppendTo[eqs, {c[[i]] == d[[i]]}], {i, Length[c]}];
Solve[Flatten@eqs, vars]

Mathematica graphics


To answer the extra question:

 sol = Solve[Flatten@eqs, vars]
 Sum[Subscript[a, i - n]*x^i, {i, n, n*m}]

Mathematica graphics

 % /. sol

Mathematica graphics

 poly = First[%]

Mathematica graphics

share|improve this answer
Super answer; thank you. – Svend Tveskæg Oct 21 '13 at 1:13
Come to think of it, why use c = CoefficientList[Expand@rhs, x]; instead if c = CoefficientList[rhs, x];, i.e., why use Expand? – Svend Tveskæg Oct 21 '13 at 5:02
@SvendTveskæg Expand is not needed. I was doing something else before and left it there. Yes, you can remove the Expand command. It does not do anything. Will update. Thanks. – Nasser Oct 21 '13 at 5:48
Great. Also, nice with ClearAll. – Svend Tveskæg Oct 21 '13 at 7:42
One last thing: Can I remove the curly braces around the last output? – Svend Tveskæg Oct 21 '13 at 9:09

First, let's rewrite your equations into a single polynomial (I've also replaced the subscript notation and removed the TraditionalForm because these are display commands and not directly relevant to solving the problem).

p[x_] := FullSimplify[
  Sum[(-1)^(i + 1)*Binomial[n, i]*x^(m*i), {i, 0, n}] - 
  Sum[(-1)^(j + 1)*Binomial[n, j]*x^j, {j, 0, n}]*
  Sum[a[i]*x^i, {i, 0, n*(m - 1)}]]

Now make a list of all the coefficients of each power of x:

c = CoefficientList[p[x], x]

And solve for the unknown a[i]'s

Solve[c == 0, {a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9]}]
{{a[0] -> 1, a[1] -> 3, a[2] -> 6, a[3] -> 10, a[4] -> 12, a[5] -> 12,
  a[6] -> 10, a[7] -> 6, a[8] -> 3, a[9] -> 1}}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.