# What is the diagonal length?

Computes the diagonal of a rectangle, square, box (rectangular prism) or cube from its sides, or the missing side of a rectangle from its diagonal, with the exact root.

- Page: https://www.acalculator.org/math/diagonal-calculator
- JSON spec: https://www.acalculator.org/math/diagonal-calculator.json
- Version: 8dee7c216206

## Default answer

Example with the default inputs (Shape Rectangle, Length (l) 4, Width (w) 3, Unit None): The diagonal is 5.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| shape | Shape | The shape whose diagonal you want, or a rectangle’s missing side from its diagonal. |
| l | Length (l) | The length of the rectangle or box, or the side you know. |
| w | Width (w) | The width of the rectangle or box. |
| h | Height (h) | The height of the box. |
| s | Side (s) | The side of the square or cube. |
| d | Diagonal (d) | The diagonal of the rectangle, longer than the side you know. |
| u | Unit | The unit of the sizes you type; the answer is in the same unit. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| d | Diagonal | The diagonal (or, for a missing side, the other side), in the unit of the sides. |
| exact | Exact value | The answer as a simplified square root of the exact fraction, such as 5√2. |
| squared | Square of the answer | The sum (or difference) of the squares under the root, before the square root. |
| angle | Angle with the length (°) | For a rectangle or square, the angle in degrees between the diagonal and the length side. |
| what | Answer is | What the answer measures: the diagonal, or the other side. |
| shown | Answer with unit | The answer to 10 significant figures, with the unit you chose. |

## Method

Rectangle: d = √(l² + w²); square: d = s√2; box: d = √(l² + w² + h²); cube: d = s√3; missing side: w = √(d² − l²).

## Assumptions

- Every size is in the same unit, from 0.000000001 to 1,000,000,000.
- Rectangles and boxes have right angles at every corner.
- For a missing side, the diagonal must be longer than the side you know.

## Worked examples

1. shape = rectangle, l = 4, w = 3, u = none gives d = 5, squared = 25, exact = 5, angle = 36.869898. Source: OpenStax, Algebra and Trigonometry 2e, §2.1 The Rectangular Coordinate Systems and Graphs (distance formula, from the Pythagorean theorem). https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-1-the-rectangular-coordinate-systems-and-graphs.
2. shape = square, s = 5, u = cm gives d = 7.071068, exact = 5√2 cm, angle = 45. Source: OpenStax, Algebra and Trigonometry 2e, §2.1 The Rectangular Coordinate Systems and Graphs (distance formula, from the Pythagorean theorem). https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-1-the-rectangular-coordinate-systems-and-graphs.
3. shape = box, l = 4, w = 3, h = 12, u = none gives d = 13, squared = 169, exact = 13. Source: OpenStax, Calculus Volume 3, §2.2 Vectors in Three Dimensions (distance between two points in space). https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions.
4. shape = cube, s = 2, u = ft gives d = 3.464102, exact = 2√3 ft. Source: OpenStax, Calculus Volume 3, §2.2 Vectors in Three Dimensions (distance between two points in space). https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions.
5. shape = side, l = 48, d = 55, u = in gives d = 26.851443, squared = 721, exact = √721 in. Source: OpenStax, Algebra and Trigonometry 2e, §2.1 The Rectangular Coordinate Systems and Graphs (distance formula, from the Pythagorean theorem). https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-1-the-rectangular-coordinate-systems-and-graphs.
6. shape = rectangle, l = 1.5, w = 2, u = none gives d = 2.5, exact = 5/2. Source: OpenStax, Algebra and Trigonometry 2e, §2.1 The Rectangular Coordinate Systems and Graphs (distance formula, from the Pythagorean theorem). https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-1-the-rectangular-coordinate-systems-and-graphs.

## FAQ

### How do I find the diagonal of a rectangle?

Use the Pythagorean theorem: d = √(l² + w²). A 4 × 3 rectangle has a diagonal of √(16 + 9) = √25 = 5.

### What is the diagonal of a square?

A square with side s has a diagonal of s√2, about 1.414 × s. A square with 5 cm sides has a diagonal of 5√2 ≈ 7.071 cm.

### How do I find the diagonal of a box?

For a box l × w × h, the space diagonal (corner to opposite corner) is √(l² + w² + h²). A 4 × 3 × 12 box has a diagonal of √169 = 13. A cube with side s has a diagonal of s√3.

### How do I find a missing side from the diagonal?

Rearrange the theorem: w = √(d² − l²). A screen 48 in wide with a 55 in diagonal is √(3025 − 2304) = √721 ≈ 26.85 in high. The diagonal must be longer than the side you know.

### What angle does the diagonal make with the sides?

In a rectangle the diagonal makes an angle of arctan(w ÷ l) with the length. For a 4 × 3 rectangle that is 36.87°, and for any square it is 45°.

### Why does the answer show a square root?

Most diagonals are not whole numbers. The exact value keeps the square root, such as 2√3 for a cube with 2 ft sides, and the decimal shows it to 10 significant figures.

## Sources

- OpenStax, Algebra and Trigonometry 2e, §2.1 The Rectangular Coordinate Systems and Graphs (the distance formula, from the Pythagorean theorem). https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-1-the-rectangular-coordinate-systems-and-graphs (retrieved 2026-10-02)
- OpenStax, Calculus Volume 3, §2.2 Vectors in Three Dimensions (the distance between two points in space, √(Δx² + Δy² + Δz²)). https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions (retrieved 2026-10-02)
