How was the closed form of this alternating sum of squares calculated?

470 Views Asked by At

I am reading through this answer at socratic.org.

The question is to find the closed form of the sum $$1^{2}-2^{2}+3^{2}-4^{2}+5^{2}-6^{2}+\ldots.$$

I understand that, if the terms were added, the sum would be $$ \sum_{n=1}^{N} n^{2}=1^{2}+2^{2}+\ldots+N^{2}. $$

The person goes on to say, if the series were not alternating, the sum would be

$$ S=\frac{N(N+1)}{2} $$

But is that correct? I thought the sum of the first $N$ squares would be $$ \frac{N(N+1)(2N+1)}{6}. $$

Lastly, I understand moving the $-1$ constant out of the summation as such

$$ =-\sum_{n=1}^{N}(-1)^{n} n^{2} $$

But I am completely missing how the final closed form was calculated

$$ S_{N}=-\frac{(-1)^{N} N(N+1)}{2} $$

4

There are 4 best solutions below

7
On

It is indeed not true that $\sum_{n=1}^Nn^2=\frac{N(N+1)}{2}$ for each positive integer $N$. This is easily verified by plugging in any value $N\geq2$. Of course it is true that $\sum_{n=1}^Nn=\frac{N(N+1)}{2}$. And you are indeed correct when you say that $$\sum_{n=1}^Nn^2=\frac{N(N+1)(2N+1)}{6}.$$ Do note that if $N$ is even, say $N=2M$, then \begin{eqnarray*} \sum_{n=1}^N(-1)^{n+1}n^2 &=&\sum_{n=1}^M\big((-1)^{2n}(2n-1)^2+(-1)^{2n+1}(2n)^2\big). \end{eqnarray*} Of course $(-1)^{2n}=1$ for all $n$, and similarly $(-1)^{2n+1}=-1$. It follows that for all $n$ we have \begin{eqnarray*} (-1)^{2n}(2n-1)^2+(-1)^{2n+1}(2n)^2 &=&(2n-1)^2-(2n)^2\\ &=&(4n^2-4n+1)-4n^2\\ &=&1-4n. \end{eqnarray*} This shows that $$\sum_{n=1}^N(-1)^{n+1}n^2=\sum_{n=1}^M(1-4n).$$ From here we can use the fact that $\sum_{n=1}^Mn=\frac{M(M+1)}{2}$ to find that \begin{eqnarray*} \sum_{n=1}^M(1-4n)&=&M-4\sum_{n=1}^Mn\\ &=&M-4\cdot\frac{M(M+1)}{2}\\ &=&-2M^2-M\\ &=&-\frac{N(N+1)}{2}. \end{eqnarray*} That proves the case where $N$ is even. If $N$ is odd, say $N=2M+1$, then \begin{eqnarray*} \sum_{n=1}^N(-1)^{n+1}n^2 &=&\left(\sum_{n=1}^{2M}(-1)^{n+1}n^2\right)+N^2\\ &=&-\frac{(N-1)N}{2}+N^2\\ &=&\frac{N(N+1)}{2}. \end{eqnarray*} This shows that although the reasoning is incorrect, the conclusion does indeed hold; that $$\sum_{n=1}^N(-1)^{n+1}n^2=-(-1)^N\frac{N(N+1)}{2}.$$


Alternatively, you could note that $$1^2-2^2+3^2-4^2+5^2-\ldots=(1^2+2^2+3^2+4^2+5^2+\ldots)-2(2^2+4^2+8^2+10^2+\ldots).$$ So from your observation that $$\sum_{n=1}^Nn^2=\frac{N(N+1)(2N+1)}{6},$$ you could conclude that if $N$ is even, say $N=2M$, then \begin{eqnarray*} \sum_{n=1}^N(-1)^{n+1}n^2 &=&\left(\sum_{n=1}^{2M}n^2\right)-2\left(\sum_{n=1}^M(2n)^2\right)\\ &=&\frac{2M(2M+1)(4M+1)}{6}-8\frac{M(M+1)(2M+1)}{6}\\ &=&\frac{-12M^2-6M}{6}\\ &=&-\frac{N(N+1)}{2}. \end{eqnarray*}

0
On

A quick intuition :

If $N$ is odd

$\displaystyle S = -\sum_{n=1}^{N} (-1)^{n} n^2 = 1 + (-2^2 + 3^2) + ... + (-1)^{N+1}(-(N-1)^2 + N^2)$

Hence $\displaystyle S = 1 + 5 + 9 + ... + (2N-1) $

There are $\frac {N+1}{2} $ terms in the above expression ( which is an A.P. in with common difference of four).

Thus $\displaystyle S_{N} = \frac {N+1}{2} \cdot \frac {2N-1+1}{2} = \frac {N(N+1)}{2} $

Similarly when $N$ is even then the sum till $N-1$ is $\displaystyle S_{N-1} = \frac {(N-1)N}{2} $

Add $-N^2$ to it to get $\displaystyle S_{N} $ when N is even : $\displaystyle S_{N} = \frac {(N-1)N}{2} - N^2 = -\frac {(N+1)N}{2} $

Hope this helps, have edited the errors.

0
On

Without analyzing odd and even cases, we can also construct the closed-form formula as follows:

Using the formula $S_n-S_{n-1}=a_n$, where $a_n=(-1)^{n+1}n^2$ and define $S_n=(-1)^n\left(an^2+bn\right)$, then we have

$$\begin{align}S_n-S_{n-1}=(-1)^n(an^2+bn)+(-1)^{n}\left(a(n-1)^2+b(n-1)\right)=2a(-1)^nn^2-2n(a-b)+(a-b)=-(-1)^nn^2\end{align}$$

This implies,

$$a=b=-\frac 12$$

This means,

$$\begin{align}\sum^{n}_{k=1} (-1)^{k+1}k^2 &=(-1)^n\left(-\frac 12n^2-\frac 12n\right)\\ &=\frac 12(-1)^{n+1}n(n+1).\end{align}$$

0
On

(This answer is an expansion of my comment. It shows an alternative method for computing the sum.)

If $n$ is even, then an easy way to compute $1^2-2^2+3^2-4^2+\dots+(n-1)^2+n^2$ is to consider the difference between each pair of terms: \begin{align} &1^2-2^2+3^2-4^2+\dots+(n-1)^2+n^2 \\[4pt] =&(1-2)(1+2)+(3-4)(3+4)+\dots +((n-1)-n)((n-1)+n) \\[4pt] =&-1(1+2)-1(3+4)-\dots-1((n-1)+n) \\[4pt] =&-1(1+2+3+4+\dots+(n-1)+n) \\[4pt] =&-\frac{n(n+1)}{2} \end{align} If $n$ is odd, then $n-1$ is even, and so we can use the above formula: $$ 1^2-2^2+3^2-4^2+\dots+(n-2)^2+(n-1)^2=-\frac{(n-1)n}{2} \, . $$ Then, adding $n^2$ to both sides, we find that $$ 1^2-2^2+3^2-4^2+\dots+(n-1)^2+n^2=\frac{n(n+1)}{2} \, . $$ Therefore, regardless of the parity of $n$, $$ 1^2-2^2+3^2-4^2+\dots+(n-1)^2+n^2=(-1)^{n+1}\cdot\frac{n(n+1)}{2} \, . $$