Number of squares in a grid of dots.

In summary, the conversation discusses the problem of determining the total number of possible combinations of four dots that form a square in an n x n grid of dots. The question takes into account any size and orientation of the square, including rotations. Different approaches to solving the problem are proposed, including using a recursive formula and factoring in the number of "native" squares for each grid size. However, the exact solution remains unknown and further discussion and analysis is needed.
  • #1
Vorde
788
0
This is a problem that I just thought of the other day and am intrigued by, let me set it up.

You have an n x n grid of dots, so that each dot is 1 away from the four dots closest in each direction. My question is; for a grid of n2 dots, what is the total number of possible combinations of four dots that form a square.
Now this is not just how many 1 by 1 squares there are, they can be any size and any orientation (meaning that the sides of the square do not have to be parallel to the sides of the grid).
Now I had attempted to figure this out myself, but I've come to a problem I couldn't solve (I apologize for not using mathematical notation, I don't really know it well enough to risk misrepresenting my idea).
Here's what I came up with:

The total amount of squares can be represented by the sum of all 4 number combinations (represented by (a,b,c,d) where a, b, c, d all stand for the coordinates of a single dot) that pass two tests:

The first test is to determine whether or not those form a square. My original idea of a test if a-b=a-c=a-d=b-a and so on failed when I realized it would not pick out the difference between squares and parallelograms. My next idea is (given a square ABCD) if AC and BD are exactly [itex]\sqrt{2}[/itex] times AB,BC,CD,DA then that should imply a square, but that's where I stopped because I am not sure of that.

The second test is to test whether or not a square is not just a rotation of another square, but I have no idea how to accomplish that.

I appreciate any advice or help anyone can give.
 
Mathematics news on Phys.org
  • #2
It would be easiest to set up a recursion. I will use the notation that an [itex]n\times n[/itex] square contains side length n, that is a [itex]1\times 1[/itex] square actually contains 4 dots, [itex]2\times 2[/itex] contains 9 and in general [itex]n\times n[/itex] contains (n+1)2 dots.

As a base case, we can easily see that a [itex]1\times1[/itex] square will have just one square, itself. Let S(n) be the number of squares for an [itex]n\times n[/itex] square.

If we construct a general [itex]n\times n[/itex] square, we can see that we must add (2n + 1) [itex]1\times1[/itex] squares to our [itex]n\times n[/itex] square to obtain an [itex]n+1\times n+1[/itex] square. We need only count the squares which contain these 2n+1 1x1 to set up our recursion. If you count newly introduced [itex]2\times 2[/itex] square you will see that there will be 2n-1 of them. Counting [itex]3\times 3[/itex] will give you 2n-3, [itex]4\times 4[/itex] will give you 2n-5 and this happens all the way to [itex]n+1\times n+1[/itex] which will give you just the one.

We now have a recursive formula: [tex]S(n+1) = S(n) + \sum_{i=0}^{n}2i+1[/tex] It is well know that the sum of the odd numbers from 1 to 2n+1 is given by (n+1)2. Therefore [tex]S(n+1) = S(n) + (n+1)^2[/tex] We can see that then the number of squares in a [itex]n\times n[/itex] grid is just the sum of the first n squares, given by the formula [itex]S(n) = \frac{n(n+1)(2n+1)}{6}[/itex]
 
Last edited:
  • #3
Maybe I've not understood that entirely, but doesn't that only count squares in a rectangular alignment and not larger ones, not to mention squares that are rotated?
 
  • #4
I apologize, I didn't catch the any orientation part. I suppose you can also set up a recursion for the number of squares of alternate orientation introduced upon adding a layer. But I don't see an easy way to calculate that without breaking it into several cases.
 
  • #5
No matter, that's the part where I was running into trouble. I think that a recursion method however would be far more complicated than the way I was thinking about it once you added in other orientations though.
 
  • #6
Actually I think it should be salvageable. If we proceed again by recursion, we need only count the number of squares with off orientation "native" to the square (that is, the nxn square is the smallest possible for this orientation). It's not too difficult to see that there is exactly n-1 such squares "native" to an n by n square. Again letting S(n) be the number of squares (of any orientation this time) then we have S(1) = 1 and

[tex]S(n+1) = S(n) +\sum_{i = 0}^{n}(2i+1) + \sum_{i = 0}^{n}(2i+1)(n-i)[/tex]

I don't have a real way of solving this recursion though.

edit: mistake in formula
 
Last edited:
  • #7
I think you might have lost me, how would you factor in # of off orientation permutations on a grid-segment by grid-segment basis because the dots composing a square could be arbitrarily far away.
 
  • #8
Vorde said:
I think you might have lost me, how would you factor in # of off orientation permutations on a grid-segment by grid-segment basis because the dots composing a square could be arbitrarily far away.

What do you mean arbitrarily far away? The squares must be contained within the larger nxn square no? By symmetry, you can easily determine the number of "native" squares of any orientation.
 
  • #9
Sorry I didn't see the rest of your post previous to your last, I think I'm following what your saying, but I'm not sure what you mean by 'native'.
 
  • #10
Vorde said:
Sorry I didn't see the rest of your post previous to your last, I think I'm following what your saying, but I'm not sure what you mean by 'native'.

By native I mean the squares within the nxn grid which is not possible within an (n-1)x(n-1) grid or smaller. For example. If we take the normally oriented squares, then the largest square (and only the largest square) is "native" to the grid. Any other smaller square can be produced in an (n-1)x(n-1) grid and hence can be covered by our recursion. Now for squares of any orientation, there will be a total of n "native" squares for each nxn grid. One is just the normally oriented square mentioned above. The other n-1 is produced by rotation one dot at a time. If we label the dots with coordinates then the normal square will have corners {(0,0), (0,n),(n,0),(n,n)} and a rotated square will have corners {(0,1), (n-1,0), (1, n),(n,n-1)} and so on.
 
  • #11
Ah I see that makes sense, and simpler than my method definitely.

The only question I have is would that identify rotations on the same as different squares or the same (while I guess it doesn't matter in my original view one of the goals was to identify rotations of already counted squares and not add them).
 
  • #12
Vorde said:
The only question I have is would that identify rotations on the same as different squares or the same.

I'm not too sure what you mean by this. If it's any clarification I can write a program to generate the number for squares for you if you'd like. You can see for yourself if this solution is the one you require.
 
  • #13
Oh no no don't bother, this is just to satisfy a curiosity. Thanks a lot for your help, if I hadn't gotten it I would still be trying after my idea.
 
  • #14
As an update, the numbers I generated seem to be the four-dimensional pyramidal numbers.
 

1. How do you calculate the number of squares in a grid of dots?

The number of squares in a grid of dots can be calculated using the formula n(n+1)(2n+1)/6, where n represents the number of dots on each side of the grid.

2. Can the number of squares in a grid of dots be determined without counting each individual square?

Yes, the formula n(n+1)(2n+1)/6 can be used to determine the number of squares in a grid of dots without having to count each square manually.

3. Are there any patterns or shortcuts for determining the number of squares in a grid of dots?

Yes, there are certain patterns and shortcuts that can be used to determine the number of squares in a grid of dots. For example, in a grid with an odd number of dots on each side, the number of squares will always be a perfect square. Additionally, in a grid with an even number of dots on each side, the number of squares will always be a perfect square plus half the number of dots on each side squared.

4. How does the number of squares in a grid of dots relate to other geometric shapes?

The number of squares in a grid of dots can be related to other geometric shapes through the concept of combinatorics, which studies the number of ways to arrange objects. For example, the number of squares in a grid of dots is equivalent to the number of ways to choose 2 items from a set of n items, which is also known as the binomial coefficient.

5. Is there a limit to the number of squares in a grid of dots?

No, there is no limit to the number of squares in a grid of dots. As long as there are enough dots to form a square, the number of squares in a grid of dots can continue to increase. However, as the number of dots on each side of the grid increases, the number of squares also increases at a faster rate.

Similar threads

Replies
18
Views
1K
Replies
9
Views
818
Replies
2
Views
1K
  • General Math
Replies
2
Views
1K
  • General Math
Replies
2
Views
746
Replies
68
Views
9K
  • Linear and Abstract Algebra
Replies
9
Views
186
  • General Math
2
Replies
45
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
3K
Back
Top