Math
Rectangle and square calculator
Know two things about a rectangle, such as its area and one side, or its perimeter and diagonal? Pick that pair and the calculator finds the length, width, area, perimeter and diagonal. For a square, any single measurement is enough.
| Unit | Area |
|---|---|
| Millimetres squared (mm²) | 60000000 |
| Centimetres squared (cm²) | 600000 |
| Metres squared (m²) | 60 |
| Kilometres squared (km²) | 6.00000e-5 |
| Hectares (ha) | 0.006 |
| Inches squared (in²) | 93000.2 |
| Feet squared (ft²) | 645.835 |
| Yards squared (yd²) | 71.7594 |
| Miles squared (mi²) | 2.31661e-5 |
| Acres | 0.0148263 |
Show the working, step by step
Area, perimeter and diagonal from length and width.
A = l × w = 12 × 5 = 60 P = 2(l + w) = 2 × 17 = 34 d = √(l² + w²) = √(144 + 25) = 13
Rectangle and square formulas
Rectangle: A = l × w P = 2(l + w) d = √(l² + w²)
Square: A = s² P = 4s d = s√2
A rectangle has two unknowns, its length and width, so it takes two measurements to pin it down. A square has only one unknown, its side, so one measurement is enough. The table shows how each pair gets back to the length and width.
| You know | How the sides are found |
|---|---|
| Area and one side | other side = A ÷ side |
| Perimeter and one side | other side = P ÷ 2 − side |
| Diagonal and one side | other side = √(d² − side²) |
| Area and perimeter | l, w are the roots of x² − (P/2)x + A = 0 |
| Area and diagonal | l + w = √(d² + 2A), l − w = √(d² − 2A) |
| Perimeter and diagonal | l + w = P ÷ 2, l − w = √(2d² − (P/2)²) |
| Square: area, perimeter or diagonal | s = √A, s = P ÷ 4, s = d ÷ √2 |
A worked example
The calculator opens on a rectangle 12 m long and 5 m wide.
- Area 12 × 5 = 60 m² (645.835 ft²).
- Perimeter 2 × (12 + 5) = 34 m.
- Diagonal √(144 + 25) = √169 = 13 m. The 5–12–13 is a whole-number right triangle, which is why the diagonal comes out exact.
- The diagonal makes an angle of 22.62° with the long side, and the aspect ratio is 2.4 : 1.
Every other rectangle mode opens on the same 12 × 5 rectangle described a different way: area 60 with side 12, perimeter 34 with diagonal 13, and so on. Switching modes should always give 12 and 5 back, which makes a good check of the method.
When there is no answer
Some pairs cannot belong to any rectangle. A diagonal must be longer than either side. A perimeter of 20 cannot enclose more than 25 square units, the area of a 5 × 5 square, so “area 30, perimeter 20” has no solution. A diagonal must lie between half the perimeter ÷ √2 (the square) and half the perimeter (a rectangle squashed flat). The calculator explains which limit your numbers break.
Setting out a right angle with the diagonal
Builders check that a rectangular slab or frame is square by measuring both diagonals: if they are equal, the corners are right angles. To set a corner out from scratch, use the 3–4–5 rule, or its larger versions 6–8–10 and 5–12–13: mark 3 m along one side and 4 m along the other, and adjust until the distance between the marks is exactly 5 m.
Common questions
How do I find the width of a rectangle from its area and length?
Divide the area by the length: w = A ÷ l. A 60 m² room that is 12 m long is 60 ÷ 12 = 5 m wide. Choose “Rectangle: area and one side” above and the calculator also gives the perimeter and the diagonal.
How do I find the diagonal of a rectangle?
By Pythagoras, because the diagonal and two sides form a right triangle: d = √(l² + w²). For 12 by 5, d = √(144 + 25) = √169 = 13. For a square with side s the diagonal is s√2, about 1.41421 × s. TV and monitor sizes are quoted by this diagonal.
Can I find the sides of a rectangle from only its area and perimeter?
Yes. The length and width add up to half the perimeter and multiply to the area, so they are the two roots of x² − (P/2)x + A = 0. With area 60 and perimeter 34 that is x² − 17x + 60 = 0, giving 12 and 5. If (P/2)² is less than 4A there is no solution: no rectangle with that perimeter can enclose that much area.
Which rectangle has the largest area for a given perimeter?
The square. With perimeter P, a square has area (P/4)², and any other rectangle with the same perimeter has less. With 34 m of fencing, a square pen 8.5 m on a side encloses 72.25 m², while the 12 × 5 pen encloses only 60 m². The same square also has the shortest diagonal for its perimeter.
Is a square a rectangle?
Yes. A rectangle is any four-sided shape with four right angles, and a square is the special case where all four sides are also equal. Every rectangle formula works for a square with l = w = s, which is why the square formulas are the rectangle ones with a single letter: A = s², P = 4s, d = s√2.
Related calculators
-
Area calculator
Area of thirteen shapes, from rectangles to rings.
-
Perimeter calculator
The distance round any common shape.
-
Quadratic equation calculator
The equation behind the area-and-perimeter case.
-
Polygon calculator
Regular polygons and shapes from coordinates.