Freitag, 16. Juli 2021

Sum N square

 Sum n2

1 + 22 + 32 + 42 + … + n2 =  ?

n = 4

1 + 4 + 9 + 16 = 30

1 +

1 + 3 +

1 + 3 + 5 +

1 + 3 + 5 + 7 =

(4-0) 1 + (4-1) 3 + (4-2) 5 + (4-3) 7 = 4 + 9 +10 + 7 = 30

 

[Sum k2 with k = 1 to n] = [Sum (n-k) (2k+1) with k = 0 to n-1] =

[Sum (2n-1) k + n - 2k2 with k = 0 to n-1] =

(2n-1) (n-1) n / 2 + n2 - 2 [Sum k2  with k = 0 to n-1]

3 [Sum k2 with k = 1 to n] - 2n2 = (2n-1) (n-1) n / 2 + n2

[Sum k2 with k = 1 to n] = [(2n-1) (n-1) n + 6n2] / 6 = n [(2n - 1) (n - 1) + 6n] / 6 =

 n (n + 1) (2n +1) / 6

 

Formulas used:

[Sum 2k-1 with k = 1 to n] = n2 

[Sum k with k = 1 to n] = n (n+1) / 2