The Pythagorean Theorem Formula

The equation a2 + b2 = c2, what every letter stands for, the algebra that turns it into a formula for each side, and the versions you will meet in coordinate geometry and 3D.

By the PythagoreanTheorem.net teamUpdated 9 min read

The Pythagorean theorem formula is a2 + b2 = c2, where a and b are the legs of a right triangle and c is the hypotenuse. Solved for each side, it becomes c = √a2 + b2 for the hypotenuse, and a = √c2 − b2 or b = √c2 − a2 for a leg.

This page is about the equation itself: what the symbols mean, how the rearranged versions follow from the original by ordinary algebra, and how the same formula reappears for distances on a grid and in three dimensions. If you want the meaning behind it first, start with what the Pythagorean theorem is.

The Pythagorean equation and what each letter means

CBAabcright anglea² + b² = c²leg² + leg² = hypotenuse²Each side is named after the corneracross from it: a faces A, b faces B,and c faces the right angle at C.
The standard labels: the right angle is at C, the legs are a and b, and the hypotenuse c is the side across from the right angle.
a2 + b2 = c2

Read it aloud as "a squared plus b squared equals c squared". When superscripts are not available it is often typed as a^2 + b^2 = c^2 or simply a2+b2=c2. Each symbol has a precise job:

a and b: the legs
The two sides that meet at the right angle. It does not matter which one you call a and which b, because addition can be done in either order: a2 + b2 = b2 + a2.
c: the hypotenuse
The side opposite the right angle, always the longest side. This is the one letter you cannot swap. Putting a leg in the c position is the most common way to get a wrong answer.
The small 2: "squared"
A number times itself, a2 = a × a. Geometrically it is the area of a square whose side is a, which is why the theorem is often drawn with squares on the sides.

Labeling conventions

Mathematicians name the corners of a triangle with capital letters and each side with the lowercase letter of the corner opposite it. With the right angle at C, the hypotenuse is automatically c. Textbooks do not always follow this, so translate the formula into the names you are given:

  • In triangle PQR with the right angle at R, the hypotenuse is PQ, so PR2 + QR2 = PQ2.
  • With legs x and y and hypotenuse h, it reads x2 + y2 = h2.

The test is always the same: the side opposite the right angle sits alone on one side of the equals sign, and the two sides that form the right angle are added on the other. If you are unsure which side that is, see how to identify the parts of a right triangle.

Rearranging the formula for each side

The equation a2 + b2 = c2 links three lengths. Knowing any two, you can solve for the third with two algebra moves: get the unknown square by itself, then undo the squaring with a square root.

Solving for the hypotenuse: c = √a2 + b2

Here c2 is already alone. Write the equation the other way round and take the square root of both sides:

c2= a2 + b2c= √a2 + b2

Strictly, c2 = 25 has two solutions, c = 5 and c = −5. A length cannot be negative, so for a triangle you keep only the positive square root. That is why the formula is written c = √a2 + b2 and not c = ±√a2 + b2.

Solving for a leg: a = √c2 − b2

To get a2 by itself, subtract b2 from both sides, then take the positive square root:

a2 + b2= c2a2= c2 − b2a= √c2 − b2

This only makes sense when c > b. If the hypotenuse were not longer than the leg, c2 − b2 would be zero or negative and there would be no triangle at all.

Solving for the other leg: b = √c2 − a2

The same two moves, subtracting a2 instead:

b2= c2 − a2b= √c2 − a2

A bar model shows why subtraction is the right move. Think of c2 as a whole made of two parts, a2 and b2. Take one part away from the whole and the other part is left.

c² = 25a² = 9b² = 16samelengtha² = c² − b²= 25 − 16 = 9b² = c² − a²= 25 − 9 = 16
For the 3-4-5 triangle, c2 = 25 splits exactly into a2 = 9 and b2 = 16. Removing either part from the whole leaves the other one.

Add or subtract?Finding the hypotenuse, the longest side, means making a number bigger, so you add the squares. Finding a leg means making it smaller, so you subtract, always the smaller square from the larger.

Why you cannot simplify √a2 + b2 to a + b

It is tempting to "cancel" the square root against the squares and write c = a + b. That step is not allowed: a square root does not split over addition. The picture shows what goes wrong.

a²b²ababababSquare of side a + b:(a + b)² = a² + b² + 2abThe two grey rectangles are extra,so (a + b)² is bigger than a² + b².With a = 3 and b = 4:(3 + 4)² = 49, but 3² + 4² = 25.So √(a² + b²) ≠ a + b.
Squaring a sum produces two extra rectangles: (a + b)2 = a2 + 2ab + b2. So a + b is always longer than √a2 + b2 when both legs are positive.

For the 3-4-5 triangle, √32 + 42 = √25 = 5, but 3 + 4 = 7. The square root has to be taken of the whole sum, after you have added. The same caution applies to √c2 − b2, which is not c − b. The same square, with four copies of the triangle drawn inside it, is the starting point of the algebraic proof of the theorem.

Units in the formula

The formula only works if all three sides are measured in the same unit. Squaring a length in centimeters gives an area in square centimeters, adding two areas gives another area, and the square root brings you back to centimeters. Mix units and the arithmetic still runs, but the answer means nothing.

Example: legs of 1.5 m and 80 cm

Convert first: 80 cm = 0.8 m. Then

c2= 1.52 + 0.82 = 2.25 + 0.64 = 2.89c= √2.89 = 1.7

The hypotenuse is 1.7 m. Without converting, √1.52 + 802 ≈ 80.01, which is nonsense: a 1.5 m leg cannot add only 1 cm to an 80 cm one.

A helpful habit is to write the units in the working, c2 = 2.89 m2, so you can see that the square root turns square meters back into meters.

The formula in coordinates and in 3D

The same equation keeps reappearing in other forms. Whenever two measurements are at right angles to each other, you can combine them with it.

P(1, 1)Q(7, 9)x₂ − x₁ = 6y₂ − y₁ = 8d = 10l = 4w = 3h = 125d = 133D: d = √(l² + w² + h²)2D: d = √(Δx² + Δy²)
Left: the distance between two points is the hypotenuse of a triangle whose legs are the horizontal and vertical differences. Right: in a box, the theorem is used twice, first across the floor and then up to the far top corner.

The distance formula

On a coordinate grid, the horizontal gap between two points is x2 − x1 and the vertical gap is y2 − y1. These are the legs, so the straight-line distance is the hypotenuse:

d = √(x2 − x1)2 + (y2 − y1)2

From P(1, 1) to Q(7, 9) the gaps are 6 and 8, so d = √36 + 64 = 10. The distance formula page derives it in full, and the distance calculator does the arithmetic.

The 3D formula

For a box of length ℓ, width w and height h, the floor diagonal satisfies f2 = ℓ2 + w2. The floor diagonal and the vertical edge form a second right triangle, so the space diagonal satisfies d2 = f2 + h2. Substituting the first into the second:

d = √ℓ2 + w2 + h2

For a 4 × 3 × 12 box, the floor diagonal is √16 + 9 = 5 and the space diagonal is √25 + 144 = 13. See the Pythagorean theorem in 3D for will-it-fit problems and 3D coordinates.

Relatives of the formula

For triangles without a right angle, the law of cosines, c2 = a2 + b2 − 2abcosC, adds a correction term that disappears when C = 90°. In trigonometry, applying the theorem to a triangle with hypotenuse 1 gives the Pythagorean identity, sin2θ + cos2θ = 1.

Formula summary

To findUseQuick example
Hypotenuse cc = √a2 + b2a = 9,  b = 12 ⇒ c = √225 = 15
Leg aa = √c2 − b2c = 10,  b = 8 ⇒ a = √36 = 6
Leg bb = √c2 − a2c = 26,  a = 10 ⇒ b = √576 = 24
Whether an angle is 90°Check a2 + b2 = c27, 24, 25: 49 + 576 = 625, so yes
Distance between pointsd = √(x2 − x1)2 + (y2 − y1)2(1, 1) to (7, 9): d = 10
Diagonal of a boxd = √ℓ2 + w2 + h22 × 3 × 6 ⇒ d = √49 = 7

The check in the fourth row uses the converse of the theorem. For a one-page version of every formula on this site, print the Pythagorean theorem cheat sheet.

Worked examples

One example for each rearranged form, plus one with decimals. In each, the first step is choosing the right version of the formula.

Example 1: find the hypotenuse

The legs of a right triangle are 20 and 21. The unknown is the hypotenuse, so use c = √a2 + b2.

c= √202 + 212= √400 + 441= √841 = 29

c = 29. Check: 29 is longer than both legs and shorter than 20 + 21 = 41.

Example 2: find leg a

The hypotenuse is 61 and one leg is b = 60. The unknown is a leg, so use a = √c2 − b2.

a= √612 − 602= √3721 − 3600= √121 = 11

a = 11. A very short leg is normal when the hypotenuse is only a little longer than the other leg.

Example 3: find leg b, with a radical answer

The hypotenuse is 8 and leg a = 4. Use b = √c2 − a2.

b= √82 − 42= √64 − 16 = √48= √16 · 3 = 4√3 ≈ 6.93

b = 4√3 exactly, or about 6.93 rounded to the nearest hundredth. Simplifying √48 is covered in square roots and radicals.

Example 4: decimals

The legs are 1.2 cm and 3.5 cm. Use c = √a2 + b2, squaring the decimals carefully.

c= √1.22 + 3.52= √1.44 + 12.25= √13.69 = 3.7

c = 3.7 cm exactly. Keep every digit until the final square root; rounding 1.44 to 1.4 would give a slightly wrong answer.

For a full procedure with a decision flowchart and answer checks, see how to do the Pythagorean theorem. To check your own numbers, the Pythagorean theorem calculator shows every line of working.

Frequently asked questions

What is the formula for the Pythagorean theorem?

a2 + b2 = c2, where a and b are the legs of a right triangle and c is the hypotenuse. To find the hypotenuse use c = √a2 + b2; to find a leg use a = √c2 − b2.

How do you rearrange a² + b² = c² to find a?

Subtract b2 from both sides to get a2 = c2 − b2, then take the square root: a = √c2 − b2. For example, with c = 10 and b = 8, a = √100 − 64 = √36 = 6.

Does it matter which leg is a and which is b?

No. The two legs play the same role, and a2 + b2 equals b2 + a2. The only letter that must go in the right place is c, the hypotenuse opposite the right angle.

Why do we only take the positive square root?

An equation such as c2 = 49 is solved by both 7 and −7, but a side of a triangle is a length, and lengths are positive. So the negative solution is discarded and c = 7.

Is the distance formula the same as the Pythagorean theorem?

Yes, in different clothes. The horizontal and vertical differences between two points, x2 − x1 and y2 − y1, are the legs of a right triangle, and the distance between the points is its hypotenuse.

What is the Pythagorean formula in 3D?

For the diagonal of a box, d = √ℓ2 + w2 + h2. It comes from using the theorem twice: once across the base and once from the base diagonal up to the opposite corner.

Keep exploring