0

I am trying to help my son with a fairly basic maths question for school.

How many squares are on a standard $8\times8$ chess board?

We have solved this one quickly, and then explored a number of different ways to calculate the answer in a number of different languages, all similar to the below:

$ \text{Size} = 8 $
$ \text{Squares} = \text{FOR } 1 \text{ TO Size: Squares} = \text{Squares} + \text{Size}^2 $

Is there a way to express this kind of loop as a mathematic equation? We've searched some texts at home and online, and got to this

$N=\sum_{s=1}^n s^2$

but I'm not confident this is correct.

I'm trying to count all of the squares of any size. Where $S = 8$ (the size of a chessboard) $N$ (the number of any size square) $= (8 \times 8)+(7 \times 7)+(6 \times 6)+(5 \times 5)+(4 \times 4)+(3 \times 3)+(2 \times 2)+(1 \times 1) = 204 $.

  • Why is Size² squared? Are you trying to count all unit squares or all squares of any size? Because I don't think this counts either of those because your result appears to be Size^3. Are you trying to count the following? $$ \sum_{i=1}^8\sum_{j=1}^8 1 = \sum_{i=1}^{8} 8 = 8\cdot 8 = 8^2 $$ – Vepir Aug 23 '20 at 14:52
  • 1
    I'm trying to count all of the squares of any size.

    Where S = 8 (the size of a chessboard)

    N (the number of any size square) = (88)+(77)+(66)+(55)+(44)+(33)+(22)+(11) = 204

    Thanks for the super-speedy response @Vepir !

    – D10N-CB3 Aug 23 '20 at 14:58
  • @user3190686 You should probably add your comment in the question to clarify it. – mathcounterexamples.net Aug 23 '20 at 15:00
  • 1
  • Well the following pesudocode [set z=0, then do (FOR i=x TO y) { z = z + a(i) }, then return z.] would be the summation notation in mathematics:

    $$ \left(\sum_{i=x}^y a(i)\right) $$

    Then for your problem, you can substitute: $a(i)=i^2$ and $x=1,y=8$.

    P.S. The wolfram alpha recognizes the "sum" command.

    – Vepir Aug 23 '20 at 15:08
  • Possible duplicate: Correct Notation for Loop. (but it is an old post with no accepted answers) – Vepir Aug 23 '20 at 15:13
  • Thanks @vepir that notation is what I am after I think! (I've just done the "lazy checking" approach and popped it into an equation solver and it's given the expected response!) – D10N-CB3 Aug 23 '20 at 15:20
  • @Aniruddha Deb has given another great answer that also works using the sum of squares (that I will now go and read up about!). – D10N-CB3 Aug 23 '20 at 15:21

1 Answers1

0

A Recurrence relation is probably your best bet here: $$n_i = n_{i-1} + n^2$$ This explains it pretty well: here's an expansion of the first few terms: $$\begin{align} n_1 &= 1 \\ n_2 &= 1 + 4 = 5 \\ n_3 &= 5 + 9 = 14 \\ ... \\ n_8 &= 140 + 64 = 204 \end{align}$$

You can also use this direct formula for the sum of squares: $$n_i = \frac{i(i+1)(2i+1)}{6}$$ This directly gives you $n_8 = \frac{8 \times 9 \times 17}{6} = 204$

Aniruddha Deb
  • 4,345
  • 11
  • 30