4 ms·
Mathematically the set of squares and the set of rectangles have the same cardinality as there is a bijection between them. To see this, a square can be descri
by vlasev 6y ago
Mathematically the set of squares and the set of rectangles have the same cardinality as there is a bijection between them.
To see this, a square can be described by a single number, putting the set of squares in 1 to 1 correspondence with the real number line. A rectangle can be described by two numbers, so the set of rectangles is in 1 to 1 correspondence with the plane.
The line and the plane have the same cardinality, so this means the sets have the same size. For example: https://math.stackexchange.com/questions/243590/bijection-from-mathbb-r-to-mathbb-rn https://math.stackexchange.com/questions/243590/bijection-fr...
- Twisol 6y agoYou aren't technically wrong, but in the colloquial sense of the comment you responded to, "smaller than" means "has a natural non-surjective inclusion into".
- kmill 6y agoYeah, and putting a natural measure on the space of rectangles, squares are a measure-zero subset. In other words there are so many rectangles, almost no rectangles are squares.
- Twisol 6y agoOoh, I like that one. For observers: fix the lower-left corner of your rectangles at the origin. Then a rectangle is determined by the position of its upper-right corner within the upper-right quadrant. The set of all rectangles is given by the entire quadrant. The set of all squares is the 45-degree line from the origin cutting the quadrant in half. The natural measure on a set of points in this space is "area". The entire quadrant has infinite area, but no matter how infinite in extent the line is, it has zero area. (In the context of probability, of which measure theory is an application, the likelihood of throwing a dart at the upper-right quadrant and hitting the line of squares is nil.) (You might argue that my choice of origin is "not natural", but it gives the same scheme as the natural "rectangle is (width, length) pair" and is a little more graphically intuitive. Every choice of corner as origin would give an isomorphic setup, resulting in the same subset-zero argument.)
- jaen 6y agoThat's only if you consider rectangles / squares in R^2. Of course, no such squares actually exist in the real world :) In computers, you're dealing with integers or floating point, and in them the set of rectangles / squares have the same measure.
- skybrian 6y agoBut this isn't relevant to computer programming because floating point numbers don't work like this. You can't pack two floating point numbers into one of the same size without losing precision. You could convert any two arbitrary-length datatypes into one, though, with a suitable encoding.