If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

# Sum of n squares (part 1)

## Video transcript

what I want to do in this video is come up with an expression for finding the sum from I equals 0 to n of I squared so if I were to expand this out this is equal to this is equal to 0 squared plus 1 squared plus 2 squared plus 3 squared and we're gonna keep on going all the way to N squared so my goal is to find some type of a function that you give me the N and I will find the sum from 0 squared 1 squared 2 squared all the way to N squared and so you command it that'd be useful because this might be okay if n is reasonably small but if n is a big number this is going to take you forever to do so let's first study this let's study what kind of the input and the output of this function needs to be so the input is going to be our n so here we're starting with so n can go from 0 all the way and we'll just try up a bunch of values so it could be 0 and could be we could go from 0 all the way to 0 and could be 1 and it could be 2 and could be 3 and we could just keep on going on and on and on but I'll just stop there for now actually let's just go to 4 just for fun and now for each of these let's see what the output of our function should be the output of the function it should be this thing it should be the sum from I equals 0 to n of I squared so when n is 0 well that's just going to be 0 squared we just stop right over there so that's just 0 when n is 1 it's 0 squared plus 1 squared so that is 1 when n is 2 0 squared plus 1 squared plus 2 squared so that's 1 plus Phi a 1 plus 4 which is 5 when n is 3 now we go all the way to 3 so it's going to be 1 plus 4 which is 5 plus 9 so 5 plus 9 is 14 and then when n is 4 we're gonna go we're gonna add the 16 4 squared to this so this gets us to 30 and of course we could keep going on and on and on so let's study this a little bit to think about what type of annex what type of a function we might be that might for each of these inputs might give us this type of an output so let's first look at the difference between these terms so a difference here is one difference here is four this is obvious we added 1 here we added 2 squared here we added 3 squared or 9 here we added 4 squared or 16 here and the reason why I'm doing this is if this was a linear function then the difference between successive terms would be the same now if this is a quadratic function then the differences between the differences would be the same let's see if that's the case so the difference here is 1 the difference here is 4 so the difference between those is 3 difference here is is 5 difference here is 7 so even the difference of the differences is increasing but if this is a cubic function then did the differences of the difference of the difference should be constant so let's see if that's the case and you'll appreciate this even more when you start learning calculus so let's see the difference between 3 the different 3 and 5 is 2 the difference between 5 and 7 is 2 and so we keep having a constant shift of 2 so the fact that the difference of the difference of the difference is fixed tells us that we should be able to express this as some type of a cubic function so this we could write as this should be equal to some function in terms of N and we could write it as a n to the third plus B n squared plus C times n plus D and now we can just use the what the inputs are and the outputs are of these to solve for a B C and D and I encourage you to I encourage you to to do that well let's first think about when n is equal to 0 when n is equal to 0 this function evaluates to D so this function evaluates to D and but this saw but that function needs to evaluate to 0 so D needs to be 0 so I'm just trying to fix those these letters here to get the right outputs so when n is 0 this expression evaluates to D and it needs to evaluate to 0 so D needs to be equal to 0 so D is equal to 0 or we could just ignore it so that helps us a little bit we know from this data point we're able to whittle it down to it having this form right over here and so now we can take each of these inputs figure out what and figure out what the corresponding output is so let's do that that over here so when n is one this thing evaluates to when n is one we just in a new color when n is one this thing evaluates to a times one third to one to the third power which is just one plus B times one squared which is just 1 plus C times 1 which is a C and this needs to be equal to 1 it needs to be equal to 1 now when when n is 2 when n is 2 we have a times n to the third so that's 8a 8a + 2 squared is 4 + 4 b + 2 c needs to be equal to 5 it needs to be equal to 5 and i need to set up three equations if i want to solve for three unknowns and so let's go to 3 so a times 3 to the third power so that's gonna be 27 a 27 a plus 9b plus 9b plus 3c plus 3c is going to be equal to is going to be equal to 14 so I've set up an equation three equations and three unknowns now I just have to solve these for a B and C and I will have a generalized I will have a generalized a generalized formula for finding the sum of the first of finding this sum right over here this sum of the first n squared the first n numbers squared I guess you could call it so what I want to do now is I'm gonna stop this video I encourage you to try to solve the simultaneous equation on your own in the next video I'll actually go and solve it