Summation Notation
Published: 2023-02-10 18:11:57

I decide to learn Artificial Intelligence with C++. When i was reading some blog's about AI, i found out that i need to learn some mathematics. Then i started searching about what i need to learn. 

I found a blog post about what math needed to learn. Here is the link.

[All the Math You Need to Know in Artificial Intelligence](https://www.freecodecamp.org/news/all-the-math-you-need-in-artificial-intelligence/)

---
In summation subject i started watching a video which is 


{% embed https://www.youtube.com/watch?v=XJkIaw2e1Pw&t=648s %}

Video is good to see what is happening in summation notation but i need to find out the proof of these formulas.


![Summationformulas](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q14a8n8702ygv6ddyxlh.png)

---


![forI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jvlrxycxe75mlc1zlfnd.png)

Sum of the First n Positive Integers are well explained in [here](https://brilliant.org/wiki/sum-of-n-n2-or-n3/)


![sumFirst1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jscpvplkk7s7ach1lmz6.png)


![sumFirst2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yn15y57kzaik6y8vwb00.png)

We add all the number from (1 to n) `[1 + 2 + 3 + ... + (n-2) + (n-1) + n]` first. Then add all of them from (n to 1) `[n + (n-1) + (n-2) + ... 3 + 2 + 1]` second. If we add these two sums bottom to bottom we get values (n + 1) summed for n times `(n + 1) * n`. Because of we use sum of all the values for 2 times (first and second), we need to divide the whole sum by 2.`[(n + 1)* n] / 2`. That is okay and the image below explains it beautifully. Learning from the image is a better way i guess so i started searching for an image solution for i(square).


![firstSumImage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eg2j52u23sz7ctx7c2k1.png)

---


![forISquare](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/svshnlu76zaoh273kh1u.png)

Gaussian proof for the sum of squares?

I found out an answer [here](https://math.stackexchange.com/a/663527/1148615)


![summationSquare](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/npywscvb3722l904gitm.png)

The image above, we are drawing 3 triangle starting from 1 to n. All triangles are starting from different corners. 

- (1^2) = 1 (Using 1 for one time in triangle)[1=1]

- (2^2) = 4 (Using 2 for two times in triangle)[2+2=4]

- (3^2) = 9 (Using 3 for three times in triangle)[3+3+3=9]

- (n^2) -> (Using n for n times in square)[n+n+...+n ntimes=n^2]

So it is like adding whole sum for 3 times like the first example.

When we add all the values at the same place in all triangles, we get a (2n + 1) valued triangle.

- First Row               -> `(1 + n + n = 2n + 1)`

- First Column Second Row -> `(2 + (n - 1) + n = 2n + 1)`

Now we need to find out how many times we are using (2n+1) value in the last triangle. To understand it easily we can change all numbers to `1`.

![totalTriangle](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/du260jcn374wvo8mg52x.png)

This is exactly what we do in first example. Sum of the values from 1 to n. The answer is `[(n + 1)* n] / 2`. We use (2n + 1) for `[(n + 1)* n] / 2` times.

So now we have a triangle which have (2n + 1) value for [(n + 1)* n] / 2 times and this triangle created by 3 same triangle so the result of `[(2n + 1) * ((n + 1)* n) / 2 ]` needs to be divided by 3.
Final result is `[((2n+1) * n * (n+1)) / (2 * 3)]`.

---

I could not found any answer like this for `cube`.

If you find out, let me know.

---


Here is a song for you
https://soundcloud.com/sturmtruppen1k17/subbbb-test-mastering-by-maukook
Have a good day!