# Square

In geometry, a square is a regular quadrilateral, which means that it has four straight sides of equal length and four equal angles. Squares are special cases of rectangles, which have four equal angles, and of rhombuses, which have four equal sides. As with all rectangles, a square's angles are right angles (90 degrees, or π/2 radians), making adjacent sides perpendicular. The area of a square is the side length multiplied by itself, and so in algebra, multiplying a number by itself is called squaring.
Equal squares can tile the plane edge-to-edge in the square tiling. Square tilings are ubiquitous in tiled floors and walls, graph paper, image pixels, and game boards. Square shapes are also often seen in building floor plans, origami paper, food servings, in graphic design and heraldry, and in instant photos and fine art.
The formula for the area of a square forms the basis of the calculation of area and motivates the search for methods for squaring the circle by compass and straightedge, now known to be impossible. Squares can be inscribed in any smooth or convex curve such as a circle or triangle, but it remains unsolved whether a square can be inscribed in every simple closed curve. Several problems of squaring the square involve subdividing squares into unequal squares. Mathematicians have also studied packing squares as tightly as possible into other shapes.
Squares can be constructed by straightedge and compass, through their Cartesian coordinates, or by repeated multiplication by $i$ in the complex plane. They form the metric balls for taxicab geometry and Chebyshev distance, two forms of non-Euclidean geometry. Although spherical geometry and hyperbolic geometry both lack polygons with four equal sides and right angles, they have square-like regular polygons with four sides and other angles, or with right angles and different numbers of sides.

## Definitions

Squares can be defined in many equivalent ways. If a quadrilateral (a four-sided polygon in the Euclidean plane) satisfies any one of the following definitions, it satisfies all of them:
* A square is a rectangle with four equal sides.
* A square is a rhombus with a right angle between a pair of adjacent sides.
* A square is a rhombus with all angles equal.
* A square is a parallelogram with one right angle and two adjacent equal sides.
* A square is a quadrilateral with four equal sides and four right angles; that is, it is a quadrilateral that is both a rhombus and a rectangle
* A square is a quadrilateral where the diagonals are equal, and are the perpendicular bisectors of each other. That is, it is a rhombus with equal diagonals.
* A square is a quadrilateral with successive sides $a$, $b$, $c$, $d$ whose area is $A={\frac {1}{4}}(a^{2}+b^{2}+c^{2}+d^{2}).$
Squares are the only regular polygons whose internal angle, central angle, and external angle are all equal (they are all right angles).

## Properties

A square is a special case of a rhombus (equal sides, opposite equal angles), a kite (two pairs of adjacent equal sides), a trapezoid (one pair of opposite sides parallel), a parallelogram (all opposite sides parallel), a quadrilateral or tetragon (four-sided polygon), and a rectangle (opposite sides equal, right-angles), and therefore has all the properties of all these shapes, namely:
* All four internal angles of a square are equal (each being 90°, a right angle).
* The central angle of a square is equal to 90°.
* The external angle of a square is equal to 90°.
* The diagonals of a square are equal and bisect each other, meeting at 90°.
* The diagonals of a square bisect its internal angles, forming adjacent angles of 45°.
* All four sides of a square are equal.
* Opposite sides of a square are parallel.
All squares are similar to each other, meaning they have the same shape, and one parameter (typically the length of a side or diagonal) suffices to specify a square's size; squares of the same size are congruent.

### Measurement

A square whose four sides have length $\ell$ has perimeter $P=4\ell$ and diagonal length $d={\sqrt {2}}\ell$. (The square root of 2, appearing in this formula, is irrational, meaning that it is not the ratio of any two integers. It is approximately equal to 1.414.) A square's area is $A=\ell ^{2}={\tfrac {1}{2}}d^{2}.$ This formula for the area of a square as the second power of its side length led to the use of the term squaring to mean raising any number to the second power. Reversing this relation, the side length of a square of a given area is the square root of the area. Squaring an integer, or taking the area of a square with integer sides, results in a square number; these are figurate numbers representing the numbers of points that can be arranged into a square grid.
Since four squared equals sixteen, a four by four square has an area equal to its perimeter. That is, it is an equable shape. The only other integer rectangle with such a property is a three by six rectangle.
Because it is a regular polygon, a square is the quadrilateral of least perimeter enclosing a given area. Dually, a square is the quadrilateral containing the largest area within a given perimeter. Indeed, if A and P are the area and perimeter enclosed by a quadrilateral, then the following isoperimetric inequality holds: $16A\leq P^{2}$ with equality if and only if the quadrilateral is a square.

### Symmetry

The square is the most symmetrical of the quadrilaterals. Like all regular polygons, it is an isogonal figure, meaning that it has symmetries taking every vertex to every other vertex, and an isotoxal figure, meaning that it has symmetries taking every edge to every other edge. More strongly, the symmetries of the square and of any other regular polygon act transitively on the flags of the polygon, pairs of a vertex and edge that touch each other. This means that there is a symmetry taking each of the eight flags of the square to each other flag.
There are eight congruence transformations of the plane that take the square to itself:
* Leaving the square unchanged (the identity transformation)
* Rotation around the center of the square by 90°, 180°, or 270°
* Reflection across a diagonal, or across a centerline of the square, parallel to one of its sides.
Combining any two of these transformations by performing one after the other produces another symmetry. This operation on pairs of symmetries gives the eight symmetries of a square the mathematical structure of a point group, the dihedral group of order eight.
The wallpaper groups are symmetry groups of two-dimensional repeating patterns. For many of these groups the basic unit of repetition (the unit cell of its period lattice) can be a square, and for three of these groups, p4, p4m, and p4g, it must be a square.

### Inscribed and circumscribed circles

The inscribed circle of a square is the largest circle that can fit inside that square. Its center is at the center point of the square, and its radius (the inradius of the square) has length $r=\ell /2$. The inscribed circle touches the sides of the square at their midpoints; because it touches all four sides, the square is a tangential quadrilateral. The circumscribed circle of a square is the circle passing through the four vertices, making the square a cyclic quadrilateral. Its radius, known as the circumradius, has length $R=\ell /{\sqrt {2}}$. If the inscribed circle of a square $ABCD$ has tangency points $E$ on $AB$, $F$ on $BC$, $G$ on $CD$, and $H$ on $DA$, then for any point $P$ on the inscribed circle,$2(PH^{2}-PE^{2})=PD^{2}-PB^{2}.$ If $d_{i}$ is the distance from an arbitrary point in the plane to the $i$th vertex of a square and $R$ is the circumradius of the square, then${\frac {d_{1}^{4}+d_{2}^{4}+d_{3}^{4}+d_{4}^{4}}{4}}+3R^{4}=\left({\frac {d_{1}^{2}+d_{2}^{2}+d_{3}^{2}+d_{4}^{2}}{4}}+R^{2}\right)^{2}.$ If $L$ and $d_{i}$ are the distances from an arbitrary point in the plane to the centroid of the square and its four vertices respectively, then $d_{1}^{2}+d_{3}^{2}=d_{2}^{2}+d_{4}^{2}=2(R^{2}+L^{2})$ and $d_{1}^{2}d_{3}^{2}+d_{2}^{2}d_{4}^{2}=2(R^{4}+L^{4}),$ where $R$ is the circumradius of the square.

## Applications

Squares are so well-established as the shape of tiles that the Latin word tessera, for a small tile as used in mosaics, takes its derivation from a variant of the ancient Greek word for the number four, referring to the four corners of a square tile. Graph paper, preprinted with a square tiling, has been widely used for data visualization using Cartesian coordinates since its invention in 1794. The pixels of bitmap images, as recorded by image scanners and digital cameras or displayed on electronic visual displays, conventionally lie at the intersections of a square grid, and are often considered as small squares, arranged in a square tiling. Standard techniques for image compression and video compression, including the JPEG format, are based on the subdivision of images into larger square blocks of pixels. The quadtree data structure used in data compression and computational geometry is based on the recursive subdivision of squares into smaller squares.
Architectural structures from both ancient and modern cultures have featured a square floor plan, base, or footprint. Ancient examples include the Egyptian pyramids, Mesoamerican pyramids such as those at Teotihuacan, the Chogha Zanbil ziggurat in what is now Iran, the four-fold design of Persian walled gardens, said to model the four rivers of Paradise, and later structures inspired by their design such as the Taj Mahal in India, the square bases of Buddhist stupas, and East Asian pagodas, buildings that symbolically face to the four points of the compass and reach to the heavens. Norman keeps such as the Tower of London often take the form of a low square tower. In modern architecture, a majority of skyscrapers feature a square plan for pragmatic rather than aesthetic or symbolic reasons.
On a smaller scale, the stylized nested squares of a Tibetan mandala, like the design of a stupa, function as a miniature model of the cosmos. Some formats for film photography use a square aspect ratio, notably Polaroid cameras, medium format cameras, and Kodak Instamatic cameras. Artists whose works have used square frames and forms include Josef Albers, Kazimir Malevich and Piet Mondrian.
Baseball diamonds and boxing rings are square despite being named for other shapes. In the quadrille and square dance, four couples form the sides of a square. In Samuel Beckett's minimalist television play Quad, four actors walk along the sides and diagonals of a square.
The square go board is said to represent the earth, with the 361 crossings of its lines representing days of the year. The chessboard inherited its square shape from a pachisi-like Indian race game and in turn passed it on to checkers. In two ancient games from Mesopotamia and Ancient Egypt, the Royal Game of Ur and Senet, the game board itself is not square, but rectangular, subdivided into a grid of squares. The ancient Greek Ostomachion puzzle (according to some interpretations) involves rearranging the pieces of a square cut into smaller polygons, as does the Chinese tangram. Another set of puzzle pieces, the polyominos, are formed from squares glued edge-to-edge. Medieval and Renaissance horoscopes were arranged in a square format, across Europe, the Middle East, and China. Other recreational uses of squares include the shape of origami paper, and a common style of quilting involving the use of square quilt blocks.
Squares are a common element of graphic design, used to give a sense of stability, symmetry, and order. In heraldry, a canton (a design element in the top left of a shield) is normally square, and a square flag is called a banner. The flag of Switzerland is square, as are the flags of the Swiss cantons. QR codes are square and feature prominent nested square alignment marks in three corners. Robertson screws have a square drive socket. Crackers and sliced cheese are often square, as are waffles. Square foods named for their square shapes include caramel squares, date squares, lemon squares, square sausage, and Carré de l'Est cheese.

## Constructions
### Coordinates and equations

A unit square is a square of side length one. Often it is represented in Cartesian coordinates as the square enclosing the points $(x,y)$ that have $0\leq x\leq 1$ and $0\leq y\leq 1$. Its vertices are the four points that have 0 or 1 in each of their coordinates.
An axis-parallel square with its center at the point $(x_{c},y_{c})$ and sides of length $2r$ (where $r$ is the inradius, half the side length) has vertices at the four points $(x_{c}\pm r,y_{c}\pm r)$. Its interior consists of the points $(x,y)$ with $\max(|x-x_{c}|,|y-y_{c}|)<r$, and its boundary consists of the points with $\max(|x-x_{c}|,|y-y_{c}|)=r$.
A diagonal square with its center at the point $(x_{c},y_{c})$ and diagonal of length $2R$ (where $R$ is the circumradius, half the diagonal) has vertices at the four points $(x_{c}\pm R,y_{c})$ and $(x_{c},y_{c}\pm R)$. Its interior consists of the points $(x,y)$ with $|x-x_{c}|+|y-y_{c}|<R$, and its boundary consists of the points with $|x-x_{c}|+|y-y_{c}|=R$. For instance the illustration shows a diagonal square centered at the origin $(0,0)$ with circumradius 2, given by the equation $|x|+|y|=2$.
In the plane of complex numbers, multiplication by the imaginary unit $i$ rotates the other term in the product by 90° around the origin (the number zero). Therefore, if any nonzero complex number $p$ is repeatedly multiplied by $i$, giving the four numbers $p$, $ip$, $-p$, and $-ip$, these numbers will form the vertices of a square centered at the origin. If one interprets the real part and imaginary part of these four complex numbers as Cartesian coordinates, with $p=x+iy$, then these four numbers have the coordinates $(x,y)$, $(-y,x)$, $(-x,-y)$, and $(-y,-x)$. This square can be translated to have any other complex number $c$ is center, using the fact that the translation from the origin to $c$ is represented in complex number arithmetic as addition with $c$. The Gaussian integers, complex numbers with integer real and imaginary parts, form a square lattice in the complex plane.

### Compass and straightedge

The construction of a square with a given side, using a compass and straightedge, is given in Euclid's Elements I.46. The existence of this construction means that squares are constructible polygons. A regular $n$-gon is constructible exactly when the odd prime factors of $n$ are distinct Fermat primes, and in the case of a square $n=4$ has no odd prime factors so this condition is vacuously true.
Elements IV.6–7 also give constructions for a square inscribed in a circle and circumscribed about a circle, respectively.
* Square with a given circumcircle
* Square with a given side length, using Thales' theorem
* Square with a given diagonal

## Related topics

Because a square is a convex regular polygon with four sides, its Schläfli symbol is {4}. A truncated square is an octagon. The square is part of two infinite families of regular polytopes, one family which includes the cube in three dimensions and the hypercubes in higher dimensions, and another which includes the regular octahedron in three dimensions and the cross polytopes in higher dimensions. The cube and hypercubes can be given vertex coordinates that are all $\pm 1$, while the octahedron and cross polytopes can be given vertex coordinates that are $\pm 1$ in a single dimension and zero in all other dimensions. In two dimensions, the first system of coordinates produces an axis-parallel square, while the second system of coordinates produces a diagonal square.
The Sierpiński carpet is a square fractal, with square holes. Space-filling curves including the Hilbert curve, Peano curve, and Sierpiński curve cover a square as the continuous image of a line segment. The Z-order curve is analogous but not continuous. Other mathematical functions associated with squares include Arnold's cat map and the baker's map, which generate chaotic dynamical systems on a square, and the lemniscate elliptic functions, complex functions periodic on a square grid.

### Inscribed squares

A square is said to be inscribed in a curve whenever all four vertices of the square lie on the curve. It is an unsolved problem in mathematics, the inscribed square problem, whether every simple closed curve has an inscribed square. Some cases of this problem are known to be true; for instance, it is true for every smooth curve. For instance, a square can be inscribed on any circle, which becomes its circumscribed circle. As another special case of the inscribed square problem, a square can be inscribed on the boundary of any convex set. The only other regular polygon with this property is the equilateral triangle. More strongly, there exists a convex set on which no other regular polygon can be inscribed.
For an inscribed square in a triangle, at least one of the square's sides lies on a side of the triangle. Every acute triangle has three inscribed squares, one lying on each of its three sides. In a right triangle there are two inscribed squares, one touching the right angle of the triangle and the other lying on the opposite side. An obtuse triangle has only one inscribed square, with a side coinciding with part of the triangle's longest side. An inscribed square can cover at most half the area of the triangle it is inscribed into.

### Area and quadrature

Conventionally, since ancient times, most units of area have been defined in terms of various squares, typically a square with a standard unit of length as its side, for example a square meter or square inch. The area of an arbitrary rectangle can then be simply computed as the product of its length and its width, and more complicated shapes can be measured by conceptually breaking them up into unit squares or into arbitrary triangles.
In ancient Greek deductive geometry, the area of a planar shape was measured and compared by constructing a square with the same area by using only a finite number of steps with compass and straightedge, a process called quadrature or squaring. Euclid's Elements shows how to do this for rectangles, parallelograms, triangles, and then more generally for simple polygons by breaking them into triangular pieces. Some shapes with curved sides could also be squared, such as the lune of Hippocrates and the parabola.
This use of a square as the defining shape for area measurement also occurs in the Greek formulation of the Pythagorean theorem: squares constructed on the two sides of a right triangle have equal total area to a square constructed on the hypotenuse. Stated in this form, the theorem would be equally valid for other shapes on the sides of the triangle, such as equilateral triangles or semicircles, but the Greeks used squares. In modern mathematics, this formulation of the theorem using areas of squares has been replaced by an algebraic formulation involving squaring numbers: the lengths of the sides and hypotenuse of the right triangle obey the equation $a^{2}+b^{2}=c^{2}$.
Because of this focus on quadrature as a measure of area, the Greeks and later mathematicians sought unsuccessfully to square the circle, constructing a square with the same area as a given circle, again using finitely many steps with a compass and straightedge. In 1882, the task was proven to be impossible as a consequence of the Lindemann–Weierstrass theorem. This theorem proves that pi (π) is a transcendental number rather than an algebraic irrational number; that is, it is not the root of any polynomial with rational coefficients. A construction for squaring the circle could be translated into a polynomial formula for π, which does not exist.

### Tiling and packing

The square tiling, familiar from flooring and game boards, is one of three regular tilings of the plane. The others are the tilings made from the equilateral triangle and the regular hexagon. The vertices of the square tiling form a square lattice. Squares of more than one size can also tile the plane, for instance in the Pythagorean tiling, named for its connection to proofs of the Pythagorean theorem.
Square packing problems seek the smallest square or circle into which a given number of unit squares can fit. A chessboard optimally packs a square number of unit squares into a larger square, but beyond a few special cases such as this, the optimal solutions to these problems remain unsolved; the same is true for circle packing in a square. Packing squares into other shapes can have high computational complexity: testing whether a given number of unit squares can fit into an orthogonally convex rectilinear polygon with half-integer vertex coordinates is NP-complete.
Squaring the square involves subdividing a given square into smaller squares, all having integer side lengths. A subdivision with distinct smaller squares is called a perfect squared square. Another variant of squaring the square called "Mrs. Perkins's quilt" allows repetitions, but uses as few smaller squares as possible in order to make the greatest common divisor of the side lengths be 1. The entire plane can be tiled by squares, with exactly one square of each integer side length.
In higher dimensions, other surfaces than the plane can be tiled by equal squares, meeting edge-to-edge. One of these surfaces is the Clifford torus, the four-dimensional Cartesian product of two congruent circles; it has the same intrinsic geometry as a single square with each pair of opposite edges glued together. Another square-tiled surface, a regular skew apeirohedron in three dimensions, has six squares meeting at each vertex. The paper bag problem seeks the maximum volume that can be enclosed by a surface tiled with two squares glued edge to edge; its exact answer is unknown. Gluing two squares in a different pattern, with the vertex of each square attached to the midpoint of an edge of the other square (or alternatively subdividing these two squares into eight squares glued edge-to-edge) produces a pincushion shape called a biscornu.

### Counting

A common mathematical puzzle involves counting the squares of all sizes in a square grid of $n\times n$ squares. For instance, a square grid of nine squares has 14 squares: the nine squares that form the grid, four more $2\times 2$ squares, and one $3\times 3$ square. The answer to the puzzle is $n(n+1)(2n+1)/6$, a square pyramidal number. For $n=1,2,3,\dots$ these numbers are:
A variant of the same puzzle asks for the number of squares formed by a grid of $n\times n$ points, allowing squares that are not axis-parallel. For instance, a grid of nine points has five axis-parallel squares as described above, but it also contains one more diagonal square for a total of six. In this case, the answer is given by the 4-dimensional pyramidal numbers $n^{2}(n^{2}-1)/12$. For $n=1,2,3,\dots$ these numbers are:
Another counting problem involving squares asks for the number of different shapes of rectangle that can be used when dividing a square into similar rectangles. A square can be divided into two similar rectangles only in one way, by bisecting it, but when dividing a square into three similar rectangles there are three possible aspect ratios of the rectangles, 3:1, 3:2, and the square of the plastic ratio. The number of proportions that are possible when dividing into $n$ rectangles is known for small values of $n$, but not as a general formula. For $n=1,2,3,\dots$ these numbers are:

### Non-Euclidean geometry

Squares tilted at 45° to the coordinate axes are the metric balls for taxicab geometry, the $L_{1}$ distance metric in the real coordinate plane. According to this metric, the distance between any two points $(x_{1},y_{1})$ and $(x_{2},y_{2})$ is $|x_{1}-x_{2}|+|y_{1}-y_{2}|$ instead of the Euclidean distance ${\sqrt {|x_{1}-x_{2}|^{2}+|y_{1}-y_{2}|^{2}}}$. The points with taxicab distance $d$ from any given point form a diagonal square, centered at the given point, with diagonal length $2d$. In the same way, axis-parallel squares form the metric balls for the $L_{\infty }$ distance metric (called the Chebyshev distance), for which the distance is given by the formula $\max(|x_{1}-x_{2}|,|y_{1}-y_{2}|)$. In this metric, the points with distance $d$ from some point form an axis-parallel square, centered at the given point, with side length $2d$.
Other forms of non-Euclidean geometry, including spherical geometry and hyperbolic geometry, also have polygons with four equal sides and equal angles. These are often called squares, but some authors avoid calling them that, instead calling them regular quadrilaterals, because unlike Euclidean squares they cannot have right angles. These geometries also have regular polygons with right angles, but with numbers of sides different from four.
In spherical geometry, a square is a polygon whose edges are great-circle arcs of equal length, which meet at equal angles. Unlike the square of Euclidean geometry, spherical squares have obtuse angles, larger than a right angle. Larger spherical squares have larger angles. An octant of a sphere is a regular spherical triangle consisting of three straight sides and three right angles. The sphere can be tiled by eight such octants to make a spherical octahedron, with four octants meeting at each vertex.
In hyperbolic geometry, squares with right angles do not exist. Rather, squares in hyperbolic geometry have acute angles, less than right angles. Larger hyperbolic squares have smaller angles. It is also possible to make a regular hyperbolic polygon with right angles at every vertex and any number of sides greater than four; such polygons can uniformly tile the hyperbolic plane.
* Subdividing a sphere into hemispheres forms a dihedron with spherical square faces and 180° angles. The Peirce quincuncial projection for world maps conformally maps these faces to Euclidean squares.
* Six squares can tile the sphere with 3 squares around each vertex and 120° internal angles. This is called a spherical cube.
* Squares can tile the hyperbolic plane with five around each vertex, each square having 72° internal angles, giving the order-5 square tiling. For any n ≥ 5 there is a hyperbolic tiling with n squares about each vertex.
* Regular hexagons with right angles can tile the hyperbolic plane with four hexagons meeting at each vertex, giving the order-4 hexagonal tiling. For any n ≥ 5 there is a hyperbolic tiling by right-angled regular n-gons, dual to the tiling with n squares about each vertex.