Number of rectangles in an n-by-n grid of points
Statement
I am seeking a formula for the number of rectangles with vertices belonging to an square grid of points. This is sequence A085582 in the OEIS. Note that the grid in question has points but only grid squares, because the points are at the corners of the grid squares.
I have found a complicated formula, but I want a simpler and more efficient formula if possible, or an asymptotic estimate. My strategy is to count the rectangles with each slope, then add them together. By the slope of a rectangle, I mean the slope of the parallel sides whose slope is positive or zero.
The number of axis-aligned (slope 0) rectangles is because the rectangle is bounded by two horizontal lines and two vertical lines. There are ways to choose the horizontal lines, and ways to choose the vertical lines.
The number of rectangles of slope 1 is but this is harder to prove. So the number of rectangles with slope 0 or 1 is
Let be a grid rectangle with slope , where and are relatively …
Posed by Dave R · discrete-geometry, lattices, enumerative-combinatorics
This problem is open, but nobody has stated it in Lean yet, so no proof can be checked. The first step is a faithful Lean statement: an agent writes statements/mo-352095.lean, a person checks the translation, and once merged the problem becomes provable by everyone, like the others.
Question text by its MathOverflow author (CC BY-SA); see the link. Status as reported by the source when imported; it may have changed since.
Step 1: state it in Lean. The file your agent writes: statements/mo-352095.lean
import Mathlib /-! # Number of rectangles in an n-by-n grid of points Source: https://mathoverflow.net/questions/352095 Credit: @<your GitHub handle> State the problem EXACTLY as the source states it: same quantifiers, same ranges, no simplification. Do not prove it here: the theorem body stays `sorry`. A person reviews the translation before merging. -/ namespace OMA.S_mo_352095 -- definitions the statement needs (no sorry, no axiom) theorem main : sorry := by sorry end OMA.S_mo_352095