0

I was solving Project Euler's problem # 6, where one has to find the sum of square of numbers from 1 to 100. I solved it using code and downloaded the Overview provided, to learn from it but I can't understand how the author has formed the function for finding the sum of square of numbers from 1 to n.

I've attached an image, highlighting the part of the document I don't understand. I know this is something really straightforward but I don't get it.

Please help and thanks in advance.

enter image description here

1 Answers1

1

$$f(0)=a(0)^3+b(0)^2+c(0)+d=d$$ $$f(1)=a(1)^3+b(1)^2+c(1)+d=a+b+c+d$$ $$f(2)=a(2)^3+b(2)^2+c(2)+d=8a+4b+2c+d$$ $$f(3)=a(3)^3+b(3)^2+c(3)+d=27a+9b+3c+d$$

Have you understood this much? After this, the numeric values of $f(0)$, $f(1)$, $f(2)$ and $f(3)$ have been found manually.

This gives us 4 equations that can be solved.

  • What I don't get is how and why is the author assuming this specific function? – misfitmaniac Dec 23 '14 at 10:21
  • @misfitmaniac it does not say. You can dream of a function, if you show that it works, then it works. The author essentially said : "I have a strong gut feeling that the answer is a third degree polynomial. Which coefficients though? My gut is not that precise.. Let's assume it is a third degree polynomial; then the coefficients have to be such and such. Of course, now I have to show that the formula I found is correct! Doing this by induction is usually the best way. Is it more clear? – Ant Dec 25 '14 at 16:27
  • @Ant We have not assumed it is a 3rd degree polynomial, it is a proved fact. It becomes more obvious when you plot it on a graph. Also, you could take a 4 (or even greater, if you want to) degree polynomial of the form $an^4+bn^3+cn^2+dn+e$. This will mean we need to take $f(4)$ also. On solving the system of equations, we get the same result, with $a=0$. – ghosts_in_the_code Dec 26 '14 at 17:15
  • @user45195 no. a priori we do not know if it is a polynomial at all.. It could be anything. We suppose it is, find the correct coefficients, then show that it works. It it works, then we proved it. But a priori we assumed it was a polynomial when we had no proof about that – Ant Dec 26 '14 at 17:26
  • @Ant I didn't get you. What do you mean by 'we do not know if it is a polynomial at all'? What else could it be? – ghosts_in_the_code Dec 27 '14 at 04:59
  • @user45195 Well a priori pretty much everything! $f(n) = \lfloor{\log n}\rfloor$, or $f(n) = 2^n$. Polynomials are not the only functions that are there! :) – Ant Dec 27 '14 at 08:40
  • @Ant Okay, I've asked a question at http://math.stackexchange.com/questions/1082357/clarification-on-how-to-prove-polynomial-representations-exist-for-infinite-seri. – ghosts_in_the_code Dec 27 '14 at 12:33
  • 1
    @user45195 very nice and interesting question! One should include such a proof on you statement though, and it would probably be an overkill since the actual proof for $m=2$ is very easy. But I'll look forward for answers on your questions! :-) – Ant Dec 27 '14 at 12:37