Compute the sum\[ (a +(2n+1)d)^2- (a + (2n)d)^2 +(a + (2n-1)d)^2 - (a+(2n-2)d)^2 + \cdots + (a+d)^2 - a^2.\]

To compute the given sum, let's first simplify the general term of the sum.

Consider the expression \[(a + (2n + k)d)^2 - (a + (2n + (k - 1))d)^2,\] where $k$ is any integer. We can rewrite this expression as
\begin{align*}
&(a + (2n + k)d)^2 - (a + (2n + (k - 1))d)^2 \\
&\quad= (a + (2n + k)d + a + (2n + (k - 1))d)(a + (2n + k)d - a - (2n + (k - 1))d) \\
&\quad= (2a + (4n + k - 1)d)d.
\end{align*}
Now, let's rewrite the given sum using this simplified form:
\begin{align*}
&(a +(2n+1)d)^2- (a + (2n)d)^2 +(a + (2n-1)d)^2 - (a+(2n-2)d)^2 + \cdots + (a+d)^2 - a^2 \\
&\quad= (2a + (4n + 1)d)d + (2a + (4n - 1)d)d + \cdots + (2a + 3d)d + (2a + d)d \\
&\quad= d \left[ (2a + (4n + 1)d) + (2a + (4n - 1)d) + \cdots + (2a + 3d) + (2a + d) \right] \\
&\quad= d \sum_{k = 1}^{n + 1} (2a + (4n - (2k - 1))d).
\end{align*}
We can rewrite this sum in a simpler form:
\[
\sum_{k = 1}^{n + 1} (2a + (4n - (2k - 1))d) = \sum_{k = 1}^{n + 1} (2(n - k + 1)d + 2a) = \sum_{k = 1}^{n + 1} (2(n + 1 - k)d) + 2a(n + 1).
\]
Using the sum of an arithmetic series formula for $(n + 1)$ terms with a common difference of $2d$, we have
\[
\sum_{k = 1}^{n + 1} (2(n + 1 - k)d) = (n + 1)(2d) \cdot \frac{2(n + 1 - 1)}{2} = 2(n + 1)^2 d.
\]
Finally, substituting this result back into the simplified form of the sum, we have
\[
d \sum_{k = 1}^{n + 1} (2a + (4n - (2k - 1))d) = d \left[ 2(n + 1)^2 d + 2a(n + 1) \right].
\]
Therefore, the sum is equal to $\boxed{2(n + 1)^2 d^2 + 2ad(n + 1)}$.

n

∑ k^2 = 1/6 n(n+1)(2n+1)
k=1

well, this is just the sum(k=a .. a+2n+1)
which is just sum(k=1 .. a+2n+1) - sum(k=1 .. a-1)