# How do I expand a sum?

I have a problem with Mathematica's symbolic manipulations. As an example, consider the following expression:

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

How do I get Mathematica to expand it 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$$

What I mean is: what functions do I apply to get the product to expand and the summation operator to distribute?

-
You are requesting two changes: first to Expand the products in the summation and second to Distribute the action of Sum over the addition. Consulting the help pages for Expand and Distribute will answer your question. –  whuber Dec 26 '12 at 18:15