# How does this expand out?

I'm finding myself getting back into math related stuff for the first time in a while. So please be patient with me.

How does $\frac{(n-i)(n-i+1)}{2}$ expand out to:

$\frac{n^2 - (2i - 1)n - i + i^2}{2}$

If you could show me step by step, I would really appreciate it.

Also, I apologise, but I really didn't know what to tag this with.

-
Retagged as (algebra-precalculus). – KReiser Aug 2 '12 at 6:49

We use the distributive property: $(a+b)c=ac+bc$ and $a(b+c)=ab+ac$.

Step by step, this gives us that

$$\frac{(n-i)(n-i+1)}{2}= \frac{n(n-i+1)-i(n-i+1)}{2}$$

$$\frac{(n-i)(n-i+1)}{2}= \frac{n^2-ni+n-ni+i^2-i}{2}$$

$$\frac{(n-i)(n-i+1)}{2}= \frac{n^2-2ni+n-i^2-i}{2}$$

Now, grouping $n-2ni = -(2i-1)n$, we get that

$$\frac{(n-i)(n-i+1)}{2}= \frac{n^2-(2i-1)n-i^2-i}{2}$$

-
I appreciate the formatting you used. Thank you! – yoonsi Aug 2 '12 at 7:21
You're welcome. Glad I could help. – KReiser Aug 2 '12 at 7:43

$$(n-i)(n-i+1)=n(n-i+1)-i(n-i+1)=nn-ni+n-in+ii-i=n^2+(-i+1-i)n+i^2-i=n^2+(-2i+1)n+i^2-i$$

-

$$(n-i)(n-i+1) = (n-i)n - (n-i)i + (n-i)$$ $$= n^2 - ni - ni + i^2 + n - i = n^2 - 2ni + n - i = n^2 - n(2i + 1) - i$$

-