<s>[INST] Easy double sum trouble : $\sum_{1 \leq i,j \leq n} (i+j)^2$ There's a mistake somewhere but I really can't see where.
$\sum_{1 \leq i,j \leq n} (i+j)^2 = \sum_{i=1}^n \sum_{j=1}^n \left( i^2+2ij+j^2\right)  = \sum_{i=1}^n \left( \sum_{j=1}^n i^2 + 2i\sum_{j=1}^n j + \sum_{j=1}^n j^2\right) $
$= \sum_{i=1}^n\left( ni^2 + 2i\frac{n(n+1)}{2} + \frac{n(n+1)(2n+1)}{6}\right) $
$ = n \sum_{i=1}^n i^2 + 2\frac{n(n+1)}{2} \sum_{i=1}^n i  + \frac{n^2(n+1)(2n+1)}{6} = 2\frac{n^2(n+1)(2n+1)}{6} + 2\left( \frac{n(n+1)}{2}\right) ^2$
When I evaluate for $n=3$, analytically it gives me $156$, and manually : $4 + 9 + 9 +16+16+16+25+25+81 = 201$.
Thanks for the help !
 [/INST] The last number is $(3+3)^2$ which is $36$.
And here is analytic result $$\frac{1}{6} \left(7 n^4+12 n^3+5 n^2\right)$$
</s>