# How do I expand a sum (again)? [duplicate]

Possible Duplicate:
How do I expand a sum?

How do I expand an equation in the given form:

$\sum _{i=1}^n -2 x_i \left(-a x_i-b+y_i\right)=0$

into this form:

$-\sum _{i=1}^n x_i y_i +a \sum _{i=1}^n x_i^2+b \sum _{i=1}^n x_i=0$

I know that I've asked this question, but this answer works only if the expression is being edited at the very moment. How to expand it and to distribute sum when I have such an expression saved into variable:

$Eq=\sum _{i=1}^n -2 x_i \left(-a x_i-b+y_i\right)=0$

Distribue[Eq] and Expand[Eq] return just unchanged Eq.

Regards

f[n_] := Sum[-2 x[i] ( - a x[i] - b + y[i]), {i, n}]

• That is just something I wanted to avoid. In my calculations Eq is a result of previous derivations, and to make my code flexible I cannot define it that way f[n_]:=... I need to work with my eq expression – Misery Jan 7 '13 at 12:59