[music] Sometimes, you'll see a Greek restaurant with a name like this.
So, it's g, r, sigma, sigma, K restaurant. And my little rant here is that this does
not say Greek restaurant. It says grssk restaurant.
That sigma is really a letter S. Right?
Sigma makes the s sound. Yeah, so grssk restaurant.
Well, this sigma makes an s sound, right? So, you know, forget this Greek restaurant
story. What's another word that actually does
start with s? Alright, a word that starts with s is Sum.
So, we're going to use that giant sigma for sums.
Let's see an example. So, I'll write a big sigma for sum, and
then below the sigma, I'll write what I want to start at.
Above the sigma, I'll right what I want to end at.
And here's what I want to add up. So, in this example, I first plug in n
equals 1. Right?
And 2 times 1 minus 1 is 1. Then, I plug in n equals 2.
2 times 2 minus 1 is 3. Then, I plug in n equals 3.
2 times 3 minus 1 is 5. Then, I plug in n equals 4.
2 times 4 minus 1 is 7. Then, I plug in n equals 5.
2 times 5 minus 1 is 9. And I keep on doing this, right, until I
plug in n equals 10. Which is 2 times 10 minus 1 which is 19.
So, to evaluate this sum, right, the meaning of these symbols is just to add up
1 plus 3 plus 5 plus 7, and so on, until I get to 19.
We can compute this. Well, here we go.
Alright, 1 plus 3 is 4. 4 plus 5 is 9.
Alright, 9 plus 7 is 16. 16 plus 9 is 25.
25 plus, what's the next number in this list, is 11.
25 plus 11 is 36. 36 plus the next number that would come
after 11 and this is 13. 36 plus 13 is 49.
49 plus, the next number is 15. 49 plus 15 is 64.
64 plus 17 is the next number, right before 19.
64 plus 17 is 81. And 81 plus 19 is 100.
So, yeah. If I add up 1 plus 3 plus 5 plus 7 plus 9
all the way up 19, by just adding up the odd numbers between 1 and 19, I get 100
and that's the value of this sum. If you have some programming experience,
you can think of these sums as like loops. Formally, what does this notation mean,
right? So, I put a big summation symbol, a big
sigma. N goes from a to b, a and b are whole
numbers. And then, I've got some expression
involving n which I can write as a function of n.
And what this notation means is just to plug in all the numbers between a and b,
the whole numbers between a and b including a and b, into this expression,
and then sum them all up. Right?
Giant sigma for sum. You know, so if I wanted to expand this
out, if I want to right out what this is doing, you know, I first plug in a, then I
plug in a plus 1, then I add to that a, whatever I get when I plug in a plus 2,
and then dot, dot, dot, I keep on going, right.
And then, I get closer to the n. Right before the n, I plug in b minus 1.
And then, I finish by plugging in b and I add up all these things and that's the
value of this sum. Alright that's what this notation means.
There's one easy case where we can figure out the whole story.
What happens if we take the sum of just a constant?
Some expression that doesn't depend on the indexing variable at all.
For instance, what is the sum, as n goes from a to b, of just the constant C,
right? This is you know, sort of expression that
doesn't involve n at all. So, to compute this, all we have to know
is how many times C is being added into itself.
Right, so this is C plus C plus, and it keeps on going, you know, plus C.
But the whole issue is just how many times C appears.
And C appears b minus a plus 1 times. That, that plus 1 maybe is a little bit
confusing. But you can see that the plus 1 really
belongs there, if you plug in some specific values for, for b and a.
So, if I add C to itself, b minus a plus 1 times, this sum is really just a
multiplication problem, right. Repeated addition is called
multiplication. It's C times b minus a plus 1.
So, the sum of C as n goes from a to b is just C times b minus a plus 1.