$(1+x)^{20}=\sum_{r=1}^{20}a_rx^r$ where $a_r=\binom{20}{r}$, find the value $\mathop{\sum\sum}_{0\le i
$(1+x)^{20}=\sum_{r=1}^{20}a_rx^r$ where $a_r=\binom{20}{r}$, find the value $$\mathop{\sum\sum}_{0\le i<j\le 20}(a_i-a_j)^2$$
I first calculated the value of $\mathop{\sum\sum}_{0\le i<j\le 20}(a_j)^2$
$$A=\mathop{\sum\sum}_{0\le i<j\le 20}(a_j)^2=\frac{1}{2}\left(\mathop{\sum\sum}_{0\le i,j\le20}(a_j)^2-\sum_{0\le i\le20}a_i^2\right)=\frac{1}{2}\left(41\binom{40}{20}-\dbinom{40}{20}\right)=20\dbinom{40}{20}$$
Then I calculated the value of $\mathop{\sum\sum}_{0\le i<j\le 20}(a_ia_j)$
$$B=\mathop{\sum\sum}_{0\le i<j\le 20}(a_ia_j)=\frac{1}{2}\left(\mathop{\sum\sum}_{0\le i,j\le20}(a_ia_j)-\sum_{0\le i\le20}a_i^2\right)=\frac{1}{2}\left(2^{40}-\binom{40}{20}\right)$$
The final answer I got was $2A-2B=41\binom{41}{20}-2^{40}$
But given answer is $41\binom{42}{20}-2^{40}$
 A: From $(a_i - a_j)^2 = a_i^2 - 2 a_i a_j + a_j^2$, I'm pretty sure you want $2A - 2B$.  But your $A$ and $B$ give $2A - 2B = 41 \binom{40}{20} - 2^{40}$, which is also not the given answer, so there must be error(s) in your $A$ and/or $B$.  When I compute $A$, I get $10 \binom{40}{20}$ and when I compute $B$, I get the same value you have.  This suggests a factor of $2$ error in your computation of $A$.  I compute: $$\begin{align}
  A &= \sum_{i=0}^{20} \sum_{j=i+1}^{20} a_j^2 \\
    &= \frac{1}{2}\left( \sum_{i=0}^{20} \sum_{j=0}^{20} a_j^2  - \sum_{i=0}^{20} a_i^2 \right) \\
    &= \frac{1}{2}\left( 21 \binom{40}{20} - \binom{40}{20}\right) & &\text{(contra. your $41 \dots$) }\\
    &= 10 \binom{40}{20},
\end{align}$$ getting the expected factor of $2$ discrepancy.
With this new $A$ and the old $B$, we have $$\begin{align}
\sum_{i=0}^{20} \sum_{j=i+1}^{20} (a_i - a_j)^2 &= 2A - 2B \\
    &= 20 \binom{40}{20} - \left( 2^{40} - \binom{40}{20} \right) \\
    &= 21 \binom{40}{20} - 2^{40}.
\end{align}$$
The given answer is more than $10$ times larger than this, so I am dubious about its correctness.
Aside:  Checking numerically: $$ \begin{align}
\sum_{i=0}^{20} \sum_{j=i+1}^{20} (a_i - a_j)^2 &= 1\,795\,265\,477\,444. \\
21 \binom{40}{20} - 2^{40} &= 1\,795\,265\,477\,444. \\
41 \binom{41}{20} - 2^{40} &= 9\,934\,774\,798\,244. \\
41 \binom{42}{20} - 2^{40} &= 19\,965\,944\,276\,444.
\end{align}$$
A: Using Lagrange Identity (that is $$\sum_{i=1}^nx_i^2\sum_{j=1}^ny_i^2=\sum_{i<j}(x_iy_j-x_jy_i)^2+\left(\sum_{i=1}^nx_iy_i\right)^2.)$$, taking $n=20$, $x_r=a_r$ and $y_r=1$ we get $$20\sum_{i=1}^{20}a_i^2=\sum_{1\le i<j\le 20}(a_i-a_j)^2+\left(\sum_{i=1}^{20}a_i\right)^2...(*)$$.
Thus, remembering that $a_r=\binom{20}{r}$, we have $\sum_{i=1}^{20}a_i=2^{20}-1$ and $\sum_{i=1}^{20}a_i^2=\binom{40}{20}-1$.
Can you conclude? (Note that sum $\sum(a_i-a_j)^2$ in $(*)$ begins in 1, while you need that sum begining in 0).
