r/MathHelp • u/Bored_comedy • Apr 07 '21
Assumption for function that calculates the sum of squares not understood.
I was solving a Project Euler problem a few months ago and I found the solution of what appears to belong to the creator of the question. It was about finding a function that calculates the sum of squares.
Now, I don't think I'm allowed to share the solution, but it's quite frustrating, so I just will share part of the solution. The assumption made was that the function was in the form:
an^3 + bn^2 + cn + d.
I have no idea what prompted such an assumption. Could someone tell me on what basis this assumption was made upon?
2
u/Munch7 Apr 07 '21
This assumption is based upon patterns relating to the sum of the integers to different powers. Let’s look at a few:
k0:
Let’s say we have a sum of from k = 1 to n of k0. We could simplify this to the sum from k = 1 to n of 1. Since we are adding up a total of n 1s, the sum is n1.
k1:
Let’s say we have a sum of from k = 1 to n of k1. It can be shown that this sum is equivalent to n(n+1)/2. Expanding this gives 0.5n2 + 0.5n. So the sum of k1 is related to a second degree (n2) polynomial.
This pattern continues. So back to your question. Based on this pattern, we know that since your question is asking about the sum of integers squared the closed form will be a cubic equation (the general form is ax3 + bx2 + cx + d)
1
u/AutoModerator Apr 07 '21
This is an automated reminder:
What have you tried so far? (See Rule #2; to add an image, you may upload it to an external image-sharing site like Imgur and include the link in your post.)
Please don't delete your post. (See Rule #7)
We, the moderators of /r/MathHelp, appreciate that your question contributes to the MathHelp archived questions that will help others searching for similar answers in the future. Thank you for obeying these instructions.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/fermat1432 Apr 07 '21 edited Apr 07 '21
Make a function table and compute the differences. 1st set is 3, 5, 7, 9, etc. 2nd set is 2, 2, 2, etc. Theory of finite differences says that the number of differences to achieve a constant difference plus 1 equals the degree of the polynomial. So 2+1=3 and we have a 3rd degree polynomial
1
u/Shadowsca Apr 07 '21
One helpful but far from rigorous way to think of it is this:
The terms 12, 22, ..., n2 are on average in the order of n2 as n gets larger, and there are n of them. Therefore the sum of all the terms should be in the order of n * n2 = n3 and this is enough to tell you that you're looking for something that is at most a cubic in size.
There are still other questions though, like how you know that you're not actually looking for a quartic or a quadratic. You can however verify for large n that a quartic is simply too large, and anything less than a cubic would be too small.
Another question is why is it a polynomial to begin with. This can be verified by considering the differences between each of the sums up to n2 for all n. This has been touched upon by other commenters already but suffice it to say if the "layers" of differences are finite then the general form is a polynomial.
So from these almost heuristic arguments you've gotten that the general equation is a polynomial in the order of n3 and is hence a cubic.
1
u/iMathTutor Apr 07 '21
Let f(n) denote the sum of squares. Observe that f(n+1)-f(n)=(n+1)2 . It follows from this observation that if f is a polynomial in n it must be cubic polynomial.
1
u/plaustrarius Apr 07 '21
The assumption isnt completely obvious without studing some calculus and geometry first
It you add integers, like 1 + 2 + 3 etc. You can think of that as a stack of line segments or points all stacked up to make a triangle.
The area of that triangles is approximate base x height divided by two. The base and height should be about the same, so we get x2 /2 as a good approximation and there could be lower order linear terms to account for the errors.
The same for adding square numbers, stack the points to find the make a pyramid, counting the points looks like finding the volume so we use a cubic equation.
4
u/ko_nuts Apr 07 '21
And how are we supposed to understand what you were asked to do and what you were trying to do if you do communicate anything about that?