So I am trying to figure out a summation of all odd squares up to n. I.E if n = 9, then the output should be 10 (the odd squares <= 9 are 1 and 9, therefore 1+9 = 10). Can anyone help me out? I can't wrap my head around this one. I did one fore the summation of odd squares for n times, but this one is proving more difficult.
Asked
Active
Viewed 56 times
0
-
1Hint: the largest integer whose square is not larger than $,10,$ is $,\lfloor \sqrt{10}\rfloor,$. – dxiv May 14 '17 at 22:29
-
There's a closed form: http://m.wolframalpha.com/input/?i=sum+%282n%2B1%29%5E2+from+0+to+i&x=2&y=11 – N74 May 14 '17 at 22:43
-
I am trying to add the odd squares that are less than or equal to n, that closed form is adding odd squares up to n as the incrementer. Like my example, if i set n=9, then the output should be ten, because the odd squares <= 9 are 1 and 9, therefore the summation of n=9 should be 10 – Jacob R May 14 '17 at 23:22
1 Answers
0
$f(n) = [\sum_{k=1}^{\lfloor \sqrt{n}\rfloor}(k)^2] - [\sum_{k=1}^{\lfloor\sqrt{n}/2\rfloor}(2k)^2]$
The first sum should find all the squares, the second should remove all those with even numbers.
The sum of squares formula is ${n(n+1)(2n+1) \over 6}$, so we can simplify this down to
${\lfloor \sqrt{n}\rfloor}({\lfloor \sqrt{n}\rfloor}+1)(2*{\lfloor \sqrt{n}\rfloor} + 1) \over 6$ $-$ $4*{\lfloor \sqrt{n}/2\rfloor}({\lfloor \sqrt{n}/2\rfloor}+1)(2*{\lfloor \sqrt{n}/2\rfloor} + 1) \over 6 $.
John Lou
- 2,388
- 13
- 16
-
-
So this, actually is the same summation I got earlier when doing the summation of odd squares for n times, but I am trying to do the summation of all odd squares <= n. – Jacob R May 15 '17 at 04:34
-
so if n=9, then the odd squares that are <= 9 are: 1, 9. Therefore the sum is 10 – Jacob R May 15 '17 at 05:20
-