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
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 + b2Strictly, 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 − b2This 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 − a2A 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.
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.
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.7The 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.
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)2From 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 + h2For 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 find | Use | Quick example |
|---|---|---|
| Hypotenuse c | c = √a2 + b2 | a = 9, b = 12 ⇒ c = √225 = 15 |
| Leg a | a = √c2 − b2 | c = 10, b = 8 ⇒ a = √36 = 6 |
| Leg b | b = √c2 − a2 | c = 26, a = 10 ⇒ b = √576 = 24 |
| Whether an angle is 90° | Check a2 + b2 = c2 | 7, 24, 25: 49 + 576 = 625, so yes |
| Distance between points | d = √(x2 − x1)2 + (y2 − y1)2 | (1, 1) to (7, 9): d = 10 |
| Diagonal of a box | d = √ℓ2 + w2 + h2 | 2 × 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 = 29c = 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 = 11a = 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.93b = 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.7c = 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
- LearnHow to Do the Pythagorean Theorem, Step by StepHow to do the Pythagorean theorem in 8 steps: label the sides, add or subtract the squares, take the square root and check. Flowchart and worked examples.
- LearnThe Hypotenuse: What It Is and How to Find ItWhat the hypotenuse of a right triangle is, why it is always the longest side, and how to find it with c = √(a² + b²): five worked examples plus a trig method.
- LearnHow to Find the Missing Side of a Right TriangleHow to find a missing leg of a right triangle with a = √(c² − b²): why you subtract, five worked examples, a mental-math shortcut and impossible inputs.
- LearnThe Distance FormulaThe distance formula explained: derive it from the Pythagorean theorem, use it with negative coordinates, avoid sign mistakes and extend it to 3D.
- CalculatorsPythagorean Theorem CalculatorFree Pythagorean theorem calculator. Enter any two sides of a right triangle to find the third, with step-by-step working, exact radical answers and a drawing.
- PracticePythagorean Theorem Cheat SheetPrintable Pythagorean theorem cheat sheet: the formula and its rearrangements, the converse, special right triangles, triples, distance formulas and squares.