About this calculator The Pythagorean theorem calculator finds the third side of a right triangle from any two: given the two legs a a a and b b b it returns the hypotenuse c = a 2 + b 2 c = \sqrt{a^2 + b^2} c = a 2 + b 2 ; given the hypotenuse and one leg it solves for the other leg. It also reports the area of the triangle, a b / 2 ab/2 ab /2 .
Whenever a problem contains a right angle—a wall and the floor, the width and height of a screen, two displacements along coordinate axes, a ladder against a wall—you can use it: measure two sides and the third needs no measuring. It is also the starting point for the distance between two points , the law of cosines and the length of a vector; understanding it means understanding how “length” is defined in Cartesian coordinates.
What it does not do: it does not handle triangles without a right angle (those need the law of cosines or the law of sines), it does not judge whether three given sides can form a triangle, and it does not convert units—all three sides must use the same length unit.
Worked examples All four examples were recomputed by the engine’s pythagorean compute routine; the display convention is at most 8 decimal places with trailing zeros removed.
Example 1: the classic 3-4-5
Inputs: a = 3 a = 3 a = 3 , b = 4 b = 4 b = 4 .
a 2 + b 2 = 9 + 16 = 25 a^2 + b^2 = 9 + 16 = 25 a 2 + b 2 = 9 + 16 = 25 .
c = 25 = 5 c = \sqrt{25} = 5 c = 25 = 5 .
Area S = 3 × 4 / 2 = 6 S = 3 \times 4 / 2 = 6 S = 3 × 4/2 = 6 .
Interface shows: hypotenuse 5 , area 6 . This is the smallest integer Pythagorean triple; the ancient Chinese text Zhoubi Suanjing refers to it as “gou 3, gu 4, xian 5”.
Figure 1: the right triangle of Example 1. The hypotenuse is the side opposite the right angle and is always the longest
Example 2: solving for a leg from the hypotenuse
Inputs: c = 13 c = 13 c = 13 , b = 5 b = 5 b = 5 (a cleared).
c 2 − b 2 = 169 − 25 = 144 c^2 - b^2 = 169 - 25 = 144 c 2 − b 2 = 169 − 25 = 144 .
a = 144 = 12 a = \sqrt{144} = 12 a = 144 = 12 .
Interface shows: leg a 12 . Note that the “Area” field shows 0 here: the engine computes the area only when both legs are inputs , and the solved a a a does not take part. To see the area, enter 12 back into “Leg a” and clear the hypotenuse; the area is then 30.
Example 3: the ladder problem
A ladder 6.5 m long leans against a wall with its foot 2.5 m from the wall. How high does it reach? Here the hypotenuse is the ladder and the legs are the distance from the wall and the height.
Inputs: c = 6.5 c = 6.5 c = 6.5 , a = 2.5 a = 2.5 a = 2.5 (b cleared).
c 2 − a 2 = 42.25 − 6.25 = 36 c^2 - a^2 = 42.25 - 6.25 = 36 c 2 − a 2 = 42.25 − 6.25 = 36 .
b = 36 = 6 b = \sqrt{36} = 6 b = 36 = 6 .
Interface shows: leg b 6 . Conversely, knowing 2.5 m from the wall and 6 m high, entering a = 2.5 a = 2.5 a = 2.5 , b = 6 b = 6 b = 6 gives hypotenuse 6.5 and area 7.5 .
Example 4: irrational results and screen diagonals
Inputs: a = 1 a = 1 a = 1 , b = 1 b = 1 b = 1 : c = 2 c = \sqrt{2} c = 2 , shown as 1.41421356 (8 decimal places), area 0.5 . This was the first length in history proved not to be a fraction.
Inputs: a = 1920 a = 1920 a = 1920 , b = 1080 b = 1080 b = 1080 (the pixel width and height of a 1080p screen): diagonal 2202.90717008 pixels. If the screen is sold as 27 inches (a 27 in diagonal), solving with c = 27 c = 27 c = 27 and b = 13.24 b = 13.24 b = 13.24 (height) gives a width of 23.53088184 in—“27 inches” is the diagonal, not the width.
When the inputs do not form a right triangle
Enter c = 4 c = 4 c = 4 , b = 5 b = 5 b = 5 (a hypotenuse shorter than a leg): c 2 − b 2 = − 9 c^2 - b^2 = -9 c 2 − b 2 = − 9 has no real square root, the engine returns NaN and “Leg a” is left blank. This is not a fault: the hypotenuse is opposite the right angle and must be the longest side.
The inputs of Example 1 can be entered directly into the panel to reproduce it; set both a and b to 1 and the hypotenuse becomes 1.41421356.
Principles and derivation Why the squares of the legs add up to the square of the hypotenuse
The most visual proof is a rearrangement. Take a large square of side a + b a + b a + b ; there are two ways to cut it up:
First cut : mark a point on each of the four sides so that the large square splits into four congruent right triangles (legs a a a , b b b ) and a tilted square in the middle. The sides of the tilted square are exactly the hypotenuse c c c of the triangles, so the central area is c 2 c^2 c 2 .
Second cut : pair the same four triangles into two a × b a \times b a × b rectangles and place them in two corners of the large square; what remains is exactly one a × a a \times a a × a square and one b × b b \times b b × b square, area a 2 + b 2 a^2 + b^2 a 2 + b 2 .
Both cuts use the same four triangles and the same large square, so the remaining areas must be equal: c 2 = a 2 + b 2 c^2 = a^2 + b^2 c 2 = a 2 + b 2 .
Figure 2: two ways of cutting the same (a+b)². The four triangles are identical, so c² = a² + b²
Euclid’s Elements , Book I, Proposition 47 gives a different proof—squares are constructed outward on the three sides and the areas of the two smaller squares are shown to equal the area of the large one; Proposition 48 proves the converse : if a triangle satisfies a 2 + b 2 = c 2 a^2 + b^2 = c^2 a 2 + b 2 = c 2 , it must be right-angled. The converse is the basis of the builder’s “3-4-5” method for laying out a right angle: a triangle formed from lengths of 3, 4 and 5 has an exact 90° corner.
It is really the definition of distance
In Cartesian coordinates, the two displacements Δ x \Delta x Δ x and Δ y \Delta y Δ y from ( x 1 , y 1 ) (x_1, y_1) ( x 1 , y 1 ) to ( x 2 , y 2 ) (x_2, y_2) ( x 2 , y 2 ) are perpendicular, so the straight-line distance between the points is the hypotenuse: d = Δ x 2 + Δ y 2 d = \sqrt{\Delta x^2 + \Delta y^2} d = Δ x 2 + Δ y 2 . This is the formula of the distance calculator ; extending it to three dimensions is just one more application of Pythagoras (first the diagonal of the base, then a new right triangle with the height). The magnitude of a vector, the modulus of a complex number and the standard deviation in statistics (the square root of a sum of squared deviations) are all the same expression.
Relationship to the law of cosines
For any triangle, c 2 = a 2 + b 2 − 2 a b cos C c^2 = a^2 + b^2 - 2ab\cos C c 2 = a 2 + b 2 − 2 ab cos C . When the included angle C = 90 ° C = 90° C = 90° , cos C = 0 \cos C = 0 cos C = 0 , the last term vanishes and the law reduces to the Pythagorean theorem. The theorem is thus the special case of the law of cosines for a right angle; conversely, comparing c 2 c^2 c 2 with a 2 + b 2 a^2 + b^2 a 2 + b 2 tells you whether the angle is acute (c 2 < a 2 + b 2 c^2 < a^2+b^2 c 2 < a 2 + b 2 ) or obtuse (c 2 > a 2 + b 2 c^2 > a^2+b^2 c 2 > a 2 + b 2 ).
Pythagorean triples
Right triangles whose three sides are all integers are called Pythagorean triples. The smallest few:
( a , b , c ) (a, b, c) ( a , b , c )
Check
(3, 4, 5)
9 + 16 = 25 9 + 16 = 25 9 + 16 = 25
(5, 12, 13)
25 + 144 = 169 25 + 144 = 169 25 + 144 = 169
(8, 15, 17)
64 + 225 = 289 64 + 225 = 289 64 + 225 = 289
(7, 24, 25)
49 + 576 = 625 49 + 576 = 625 49 + 576 = 625
(20, 21, 29)
400 + 441 = 841 400 + 441 = 841 400 + 441 = 841
Euclid’s formula generates every primitive triple: take coprime positive integers m > n m > n m > n of opposite parity and set a = m 2 − n 2 a = m^2 - n^2 a = m 2 − n 2 , b = 2 m n b = 2mn b = 2 mn , c = m 2 + n 2 c = m^2 + n^2 c = m 2 + n 2 . m = 2 , n = 1 m = 2, n = 1 m = 2 , n = 1 gives (3, 4, 5); m = 3 , n = 2 m = 3, n = 2 m = 3 , n = 2 gives (5, 12, 13). Any triple scaled by a constant is still a triple—(6, 8, 10) and (0.3, 0.4, 0.5) give equally tidy results in the calculator.
History
The Babylonian tablet Plimpton 322 (c. 1800 BCE) already lists many Pythagorean triples. In China, the Zhoubi Suanjing records “gou 3, gu 4, xian 5”, the “Gougu” chapter of the Nine Chapters on the Mathematical Art systematically solves problems with the theorem, and Zhao Shuang’s commentary contains the “hypotenuse diagram”, which is precisely the rearrangement proof above. The Pythagorean school (c. 6th century BCE) is credited with the earliest general proof, and with the discovery, through 2 \sqrt{2} 2 , that some lengths cannot be written as fractions. Gou and gu are the classical Chinese names for the shorter and longer legs of a right triangle; xian is the hypotenuse.
It holds only in the plane
The Pythagorean theorem is a theorem of Euclidean plane geometry. On a sphere, two perpendicular great-circle arcs a a a and b b b and the third side c c c satisfy cos c = cos a cos b \cos c = \cos a \cos b cos c = cos a cos b (unit sphere), which approaches a 2 + b 2 = c 2 a^2 + b^2 = c^2 a 2 + b 2 = c 2 only when all three sides are much smaller than the sphere’s radius. Over a few tens of kilometres on a map, Pythagoras is safe; for intercontinental distances, use spherical formulas.