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)

What is the sum of the first n squares, 1 + 4 + 9 + 16 + ... + n²? In this video we begin the journey towards finding a formula for this sum. Created by Sal Khan.

Want to join the conversation?

  • male robot hal style avatar for user Sarthak Kumar
    - For a linear equation, the difference between successive terms is a constant.
    - For a quadratic equation, the difference of the difference between the successive terms is a constant; and
    - For a cubic equation, the difference of the difference of the difference of successive terms is a constant.

    I took this observation on its face value and understood the video but what I'm wondering is...

    Where does this insight come from? Is there a proof to it? Has Sal done a video which explains it in better detail?

    Many thanks!
    (40 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user jaxxson
      Here are proofs of those three statements:
      Proof for a linear equation of the form L(n) = A*n + B, where A and B are constant coefficients. The difference between successive terms of L(n) can be represented by:
      L(n+1) - L(n) = (A*(n+1)+B) - (A*n+B) = A*(n+1) + B - A*n - B = A*(n+1) - A*n = A, which we defined as a constant. So then the difference between successive terms of a linear equation is constant.
      Proof for a quadratic equation of the form Q(n) = A*n^2 + B*n + C, where A, B, and C are constant coefficients.
      The difference between successive terms can be represented by:
      Q(n+1) - Q(n) = (A*(n+1)^2 + B*(n+1) + C) - (A*n^2 + B*n + C) = A*(n^2+2n+1) + B*(n+1) + C - A*n^2 - B*n - C = A*(n^2+2n+1) - An^2 + B*(n+1) - B*n = A*(n^2+2n+1 - n^2) + B*(n+1 - n) = A*(2n+1) + B*1 = A*(2n+1) + B.
      Which is a linear function of n. So then Q(n+1) - Q(n) is a linear function of n and so the difference between successive terms of a quadratic series is always a linear function of n. We already proved that the difference between successive terms of a linear function is a constant, so this means that the difference between the successive terms of Q(n+1) - Q(n) is a constant, and so the difference of the difference between successive terms of Q(n) is constant. Q(n) is just any quadratic, so the difference of the difference between the successive terms of a quadratic is always constant. See if you can prove the statement for any cubic equation on your own. It's the same general method as for the linear and quadratics.
      (58 votes)
  • leaf red style avatar for user Noble Mushtak
    "You'll appreciate this even more when you get into calculus."-Sal,
    Was he referring to how the second derivative of x^2 is 2?
    (29 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Creeksider
      I believe what he was getting at is that the second derivative of a quadratic equation is always a constant, and because his second step in looking at the change between adjacent numbers did not produce a constant change, the formula can't be quadratic, which is why we go on to determine that it must be a cubic function.
      (28 votes)
  • blobby green style avatar for user Daniel
    hi Sal, I don't understand why this general function? especially why n^3, I mean I didn't get the connection between the difference of the terms and where comes the function. please explain to me
    (13 votes)
    Default Khan Academy avatar avatar for user
    • leafers ultimate style avatar for user KrisSKing
      Sal figures out that the function that results in the behavior of this series is a third degree function by looking at the differences in the series when n is 0, 1, 2, 3, and 4. If those differences were constant, that would mean that the function to model the behavior of this series would be a linear function. But the differences aren't constant. So he looks at the differences of the differences. If those were constant, which they aren't, that would mean that the function to model the behavior of this series would be a quadratic function. When he looks at the differences of the differences of the differences he does find a constant value. That means this is a cubic function. The general form of a cubic function is An^3 + Bn^2 + Cn^1 + Dn^0 or, written more simply: An^3 + Bn^2 + Cn + D, where A, B, C, and D are real numbers (including zero).
      (21 votes)
  • blobby green style avatar for user Efi Eizenberg
    At sal says the sum of 1^2 + 2^2 + ... is equal to An^3 + Bn^2 + Cn + D.
    I understand why he used An^3 + Bn^2 + Cn + D but any chance there's a video which explain that in further details?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user zzzach99
    At Sal determines that the function that gives the sum of the first n terms of the series must be cubic because the differences of the difference of the differences is constant. Is there any reason why it couldn't be some flukey quartic or quintic, or is it simply an educated guess?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • old spice man green style avatar for user Sean Murray
    Am I correct in saying that Sal finds the differences from the sequence of the partial sums?

    If so, is the notation {Sn} = 0, 1, 5, 14, 30... correct to use instead of the gaps and sigma notation Sal used from onwards?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • starky ultimate style avatar for user Darren Leung
    Ok so i was wondering how would I solve something like ((2i)^2)+i from 1 to 10?

    I got 10((5+410)/2). Which evaluates to 2075. I know it is wrong, so how would I solve it?

    Ps. This is not a homework question
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user jamie_chu78
    Hello people, so I realize that there are quite a few number of concepts introduced in this video, all of which seem to be large in size.

    First, is the concept of finding the difference of the difference of something, or the d of the d of the d of the d etc. Now, knowing mathematicians, I presume there is a shorthand for this?

    Second is the fact that the difference of a quadratic can be modelled by a cubic one. Is there a proof for this somewhere, which may provide some intuition?

    Third, I never knew that a systems of equations could be used to solve something such as this. Where does the terms A, B, and C come from, and why is there coefficients n^3, n^2, and n? What if the formula was only in the form of An^3+Cn, or A^n3+Bn^2, and so on.

    Any help would be much appreciated ^.^
    (2 votes)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user wolfffre000
      The set up of the problem has to do with whether you are working backwards, graph to equation, or forwards, from equation to graph. Each variable represents the different value that is given by a graph, or in a n equation to transfer to a graph. The reason why the equation is with the A,B, and C terms along with the coefficients n^3, n^2, and n are because in the computing of the problem. With the example of . . .

      Area PQRS = the summation of x^2 and x^1 times dx/V = 20 Sumation x^2 and x^1 dx/x = 18.33 hr.

      In this equation f(x) is a function of x [b, f(x) =1/V] . Plot x and measure the area under the curve between the vertical lines at x = x^1 and x= x^2.

      Pqrs is approx. 36.4 squares and the square LMRO is 100 squares and has an area of o.10 X 500 = 50 (hr.).

      Thusly, the integral is 36.4/100 X 50 = 18.2 hr.

      Compared with the correct value of 18.33 hr.

      The error is very little. Does this response help?
      (1 vote)
  • marcimus pink style avatar for user Jen Santelices
    How about if you have to find the sum of the same number but it's exponent continuously increases? Like 2/3 + (2/3)^2 + (2/3)^3 + (2/3)^4 + (2/3)^5? Is there a video for something similar to that?
    (1 vote)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user giobrach
    So what would the sum from i=0 to n of i^pi be? How does this work with irrational powers?
    (1 vote)
    Default Khan Academy avatar avatar for user

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 0 squared plus 1 squared plus 2 squared plus 3 squared. And we're going to 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 can imagine that'd be useful, because this might be OK 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 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 n could be 0. We could go from 0 all the way to 0. n could be 1. n could be 2. n 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 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'd 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, it's 0 squared plus 1 squared plus 2 squared. So that's 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 going to 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 a function that, 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 the difference here is 1. The difference here is 4. And 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. The difference here is 5. The difference here is 7. So even the difference of the differences is increasing. But if this is a cubic function, then 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 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 An to the third plus Bn squared plus C times n plus D. And now we can just use what the inputs are and the outputs are of these to solve for A, B, C, and D. And I encourage you 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. But that function needs to evaluate to 0, so D needs to be 0. So I'm just trying to fix 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 and figure out what their corresponding output is. So let's do that-- I'll do that over here. So when n is 1, this thing evaluates to-- let me do this in a new color-- this thing evaluates to A times 1 to the third power, which is just 1, plus B times 1 squared, which is just 1, plus C times 1, which is just C. And this needs to be equal to 1. Now, when n is 2, we have A times n to the third. So that's 8A plus 2 squared is 4, plus 4B plus 2C 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 going to be 27A, plus 9B plus 3C is going to be equal to 14. So I've set up three equations in three unknowns. Now I just have to solve these for A, B, and C. And I will have a generalized formula for finding this sum right over here, the sum of the first n numbers squared, I guess you could call it. So what I want to do now is I'm going to 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.