# Pythagorean theorem

In mathematics, the **Pythagorean theorem**, or **Pythagoras' theorem**, is a fundamental relation in Euclidean geometry among the three sides of a right triangle. It states that the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares on the other two sides. This theorem can be written as an equation relating the lengths of the sides *a*, *b* and *c*, often called the **Pythagorean equation**:^{[1]}

where *c* represents the length of the hypotenuse and *a* and *b* the lengths of the triangle's other two sides. The theorem, whose history is the subject of much debate, is named for the Greek philosopher Pythagoras, born around 570 BC.

The theorem has been proven numerous times by many different methods – possibly the most for any mathematical theorem. The proofs are diverse, including both geometric proofs and algebraic proofs, with some dating back thousands of years.

The theorem can be generalized in various ways: to higher-dimensional spaces, to spaces that are not Euclidean, to objects that are not right triangles, and to objects that are not triangles at all but *n*-dimensional solids. The Pythagorean theorem has attracted interest outside mathematics as a symbol of mathematical abstruseness, mystique, or intellectual power; popular references in literature, plays, musicals, songs, stamps, and cartoons abound.

The two large squares shown in the figure each contain four identical triangles, and the only difference between the two large squares is that the triangles are arranged differently. Therefore, the white space within each of the two large squares must have equal area. Equating the area of the white space yields the Pythagorean theorem, Q.E.D.^{[2]}

Heath gives this proof in his commentary on Proposition I.47 in Euclid's *Elements*, and mentions the proposals of Bretschneider and Hankel that Pythagoras may have known this proof. Heath himself favors a different proposal for a Pythagorean proof, but acknowledges from the outset of his discussion "that the Greek literature which we possess belonging to the first five centuries after Pythagoras contains no statement specifying this or any other particular great geometric discovery to him."^{[3]} Recent scholarship has cast increasing doubt on any sort of role for Pythagoras as a creator of mathematics, although debate about this continues.^{[4]}

If *c* denotes the length of the hypotenuse and *a* and *b* denote the lengths of the other two sides, the Pythagorean theorem can be expressed as the Pythagorean equation:

If the length of the hypotenuse *c* and of one side (*a* or *b*) are known, then the length of the other side can be calculated as

The Pythagorean equation relates the sides of a right triangle in a simple way, so that if the lengths of any two sides are known the length of the third side can be found. Another corollary of the theorem is that in any right triangle, the hypotenuse is greater than any one of the other sides, but less than their sum.

A generalization of this theorem is the law of cosines, which allows the computation of the length of any side of any triangle, given the lengths of the other two sides and the angle between them. If the angle between the other sides is a right angle, the law of cosines reduces to the Pythagorean equation.

This theorem may have more known proofs than any other (the law of quadratic reciprocity being another contender for that distinction); the book *The Pythagorean Proposition* contains 370 proofs.^{[5]}

This proof is based on the proportionality of the sides of two similar triangles, that is, upon the fact that the ratio of any two corresponding sides of similar triangles is the same regardless of the size of the triangles.

Let *ABC* represent a right triangle, with the right angle located at *C*, as shown on the figure. Draw the altitude from point *C*, and call *H* its intersection with the side *AB*. Point *H* divides the length of the hypotenuse *c* into parts *d* and *e*. The new triangle *ACH* is similar to triangle *ABC*, because they both have a right angle (by definition of the altitude), and they share the angle at *A*, meaning that the third angle will be the same in both triangles as well, marked as *θ* in the figure. By a similar reasoning, the triangle *CBH* is also similar to *ABC*. The proof of similarity of the triangles requires the triangle postulate: The sum of the angles in a triangle is two right angles, and is equivalent to the parallel postulate. Similarity of the triangles leads to the equality of ratios of corresponding sides:

The first result equates the cosines of the angles *θ*, whereas the second result equates their sines.

The role of this proof in history is the subject of much speculation. The underlying question is why Euclid did not use this proof, but invented another. One conjecture is that the proof by similar triangles involved a theory of proportions, a topic not discussed until later in the *Elements*, and that the theory of proportions needed further development at that time.^{[6]}^{[7]}

In outline, here is how the proof in Euclid's *Elements* proceeds. The large square is divided into a left and right rectangle. A triangle is constructed that has half the area of the left rectangle. Then another triangle is constructed that has half the area of the square on the left-most side. These two triangles are shown to be congruent, proving this square has the same area as the left rectangle. This argument is followed by a similar version for the right rectangle and the remaining square. Putting the two rectangles together to reform the square on the hypotenuse, its area is the same as the sum of the area of the other two squares. The details follow.

Let *A*, *B*, *C* be the vertices of a right triangle, with a right angle at *A*. Drop a perpendicular from *A* to the side opposite the hypotenuse in the square on the hypotenuse. That line divides the square on the hypotenuse into two rectangles, each having the same area as one of the two squares on the legs.

Next, each top square is related to a triangle congruent with another triangle related in turn to one of two rectangles making up the lower square.^{[8]}

This proof, which appears in Euclid's *Elements* as that of Proposition 47 in Book 1, demonstrates that the area of the square on the hypotenuse is the sum of the areas of the other two squares.^{[10]}^{[11]}
This is quite distinct from the proof by similarity of triangles, which is conjectured to be the proof that Pythagoras used.^{[7]}^{[12]}

We have already discussed the Pythagorean proof, which was a proof by rearrangement. The same idea is conveyed by the leftmost animation below, which consists of a large square, side *a* + *b*, containing four identical right triangles. The triangles are shown in two arrangements, the first of which leaves two squares *a*^{2} and *b*^{2} uncovered, the second of which leaves square *c*^{2} uncovered. The area encompassed by the outer square never changes, and the area of the four triangles is the same at the beginning and the end, so the black square areas must be equal, therefore *a*^{2} + *b*^{2} = *c*^{2}.

A second proof by rearrangement is given by the middle animation. A large square is formed with area *c*^{2}, from four identical right triangles with sides *a*, *b* and *c*, fitted around a small central square. Then two rectangles are formed with sides *a* and *b* by moving the triangles. Combining the smaller square with these rectangles produces two squares of areas *a*^{2} and *b*^{2}, which must have the same area as the initial large square.^{[13]}

The third, rightmost image also gives a proof. The upper two squares are divided as shown by the blue and green shading, into pieces that when rearranged can be made to fit in the lower square on the hypotenuse – or conversely the large square can be divided as shown into pieces that fill the other two. This way of cutting one figure into pieces and rearranging them to get another figure is called dissection. This shows the area of the large square equals that of the two smaller ones.^{[14]}

Albert Einstein gave a proof by dissection in which the pieces need not get moved.^{[15]} Instead of using a square on the hypotenuse and two squares on the legs, one can use any other shape that includes the hypotenuse, and two similar shapes that each include one of two legs instead of the hypotenuse (see Similar figures on the three sides). In Einstein's proof, the shape that includes the hypotenuse is the right triangle itself. The dissection consists of dropping a perpendicular from the vertex of the right angle of the triangle to the hypotenuse, thus splitting the whole triangle into two parts. Those two parts have the same shape as the original right triangle, and have the legs of the original triangle as their hypotenuses, and the sum of their areas is that of the original triangle. Because the ratio of the area of a right triangle to the square of its hypotenuse is the same for similar triangles, the relationship between the areas of the three triangles holds for the squares of the sides of the large triangle as well.

A similar proof uses four copies of the same triangle arranged symmetrically around a square with side *c*, as shown in the lower part of the diagram.^{[17]} This results in a larger square, with side *a* + *b* and area (*a* + *b*)^{2}. The four triangles and the square side *c* must have the same area as the larger square,

A related proof was published by future U.S. President James A. Garfield (then a U.S. Representative) (see diagram).^{[18]}^{[19]}^{[20]} Instead of a square it uses a trapezoid, which can be constructed from the square in the second of the above proofs by bisecting along a diagonal of the inner square, to give the trapezoid as shown in the diagram. The area of the trapezoid can be calculated to be half the area of the square, that is

One can arrive at the Pythagorean theorem by studying how changes in a side produce a change in the hypotenuse and employing calculus.^{[21]}^{[22]}^{[23]}

The triangle *ABC* is a right triangle, as shown in the upper part of the diagram, with *BC* the hypotenuse. At the same time the triangle lengths are measured as shown, with the hypotenuse of length *y*, the side *AC* of length *x* and the side *AB* of length *a*, as seen in the lower diagram part.

If *x* is increased by a small amount *dx* by extending the side *AC* slightly to *D*, then *y* also increases by *dy*. These form two sides of a triangle, *CDE*, which (with *E* chosen so *CE* is perpendicular to the hypotenuse) is a right triangle approximately similar to *ABC*. Therefore, the ratios of their sides must be the same, that is:

This is more of an intuitive proof than a formal one: it can be made more rigorous if proper limits are used in place of *dx* and *dy*.

For any three positive numbers *a*, *b*, and *c* such that *a*^{2} + *b*^{2} = *c*^{2}, there exists a triangle with sides *a*, *b* and *c*, and every such triangle has a right angle between the sides of lengths *a* and *b*.

For any triangle with sides *a*, *b*, *c*, if *a*^{2} + *b*^{2} = *c*^{2}, then the angle between *a* and *b* measures 90°.

This converse also appears in Euclid's *Elements* (Book I, Proposition 48):^{[25]}

"If in a triangle the square on one of the sides equals the sum of the squares on the remaining two sides of the triangle, then the angle contained by the remaining two sides of the triangle is right."

Let *ABC* be a triangle with side lengths *a*, *b*, and *c*, with *a*^{2} + *b*^{2} = *c*^{2}. Construct a second triangle with sides of length *a* and *b* containing a right angle. By the Pythagorean theorem, it follows that the hypotenuse of this triangle has length *c* = √*a*^{2} + *b*^{2}, the same as the hypotenuse of the first triangle. Since both triangles' sides are the same lengths *a*, *b* and *c*, the triangles are congruent and must have the same angles. Therefore, the angle between the side of lengths *a* and *b* in the original triangle is a right angle.

The above proof of the converse makes use of the Pythagorean theorem itself. The converse can also be proven without assuming the Pythagorean theorem.^{[26]}^{[27]}

A corollary of the Pythagorean theorem's converse is a simple means of determining whether a triangle is right, obtuse, or acute, as follows. Let *c* be chosen to be the longest of the three sides and *a* + *b* > *c* (otherwise there is no triangle according to the triangle inequality). The following statements apply:^{[28]}

Edsger W. Dijkstra has stated this proposition about acute, right, and obtuse triangles in this language:

where *α* is the angle opposite to side *a*, *β* is the angle opposite to side *b*, *γ* is the angle opposite to side *c*, and sgn is the sign function.^{[29]}

A Pythagorean triple has three positive integers *a*, *b*, and *c*, such that *a*^{2} + *b*^{2} = *c*^{2}. In other words, a Pythagorean triple represents the lengths of the sides of a right triangle where all three sides have integer lengths.^{[1]} Such a triple is commonly written (*a*, *b*, *c*). Some well-known examples are (3, 4, 5) and (5, 12, 13).

A primitive Pythagorean triple is one in which *a*, *b* and *c* are coprime (the greatest common divisor of *a*, *b* and *c* is 1).

The following is a list of primitive Pythagorean triples with values less than 100:

One of the consequences of the Pythagorean theorem is that line segments whose lengths are incommensurable (so the ratio of which is not a rational number) can be constructed using a straightedge and compass. Pythagoras' theorem enables construction of incommensurable lengths because the hypotenuse of a triangle is related to the sides by the square root operation.

The figure on the right shows how to construct line segments whose lengths are in the ratio of the square root of any positive integer.^{[33]} Each triangle has a side (labeled "1") that is the chosen unit for measurement. In each right triangle, Pythagoras' theorem establishes the length of the hypotenuse in terms of this unit. If a hypotenuse is related to the unit by the square root of a positive integer that is not a perfect square, it is a realization of a length incommensurable with the unit, such as √2, √3, √5 . For more detail, see Quadratic irrational.

Incommensurable lengths conflicted with the Pythagorean school's concept of numbers as only whole numbers. The Pythagorean school dealt with proportions by comparison of integer multiples of a common subunit.^{[34]} According to one legend, Hippasus of Metapontum (*ca.* 470 B.C.) was drowned at sea for making known the existence of the irrational or incommensurable.^{[35]}^{[36]}

So the three quantities, *r*, *x* and *y* are related by the Pythagorean equation,

Note that *r* is defined to be a positive number or zero but *x* and *y* can be negative as well as positive. Geometrically *r* is the distance of the *z* from zero or the origin *O* in the complex plane.

This can be generalised to find the distance between two points, *z*_{1} and *z*_{2} say. The required distance is given by

The distance formula in Cartesian coordinates is derived from the Pythagorean theorem.^{[37]} If (*x*_{1}, *y*_{1}) and (*x*_{2}, *y*_{2}) are points in the plane, then the distance between them, also called the Euclidean distance, is given by

If instead of Euclidean distance, the square of this value (the squared Euclidean distance, or SED) is used, the resulting equation avoids square roots and is simply a sum of the SED of the coordinates:

The squared form is a smooth, convex function of both points, and is widely used in optimization theory and statistics, forming the basis of least squares.

If Cartesian coordinates are not used, for example, if polar coordinates are used in two dimensions or, in more general terms, if curvilinear coordinates are used, the formulas expressing the Euclidean distance are more complicated than the Pythagorean theorem, but can be derived from it. A typical example where the straight-line distance between two points is converted to curvilinear coordinates can be found in the applications of Legendre polynomials in physics. The formulas can be discovered by using Pythagoras' theorem with the equations relating the curvilinear coordinates to Cartesian coordinates. For example, the polar coordinates (*r*, *θ*) can be introduced as:

Then two points with locations (*r*_{1}, *θ*_{1}) and (*r*_{2}, *θ*_{2}) are separated by a distance *s*:

Performing the squares and combining terms, the Pythagorean formula for distance in Cartesian coordinates produces the separation in polar coordinates as:

In a right triangle with sides *a*, *b* and hypotenuse *c*, trigonometry determines the sine and cosine of the angle *θ* between side *a* and the hypotenuse as:

where the last step applies Pythagoras' theorem. This relation between sine and cosine is sometimes called the fundamental Pythagorean trigonometric identity.^{[39]} In similar triangles, the ratios of the sides are the same regardless of the size of the triangles, and depend upon the angles. Consequently, in the figure, the triangle with hypotenuse of unit size has opposite side of size sin *θ* and adjacent side of size cos *θ* in units of the hypotenuse.

The Pythagorean theorem relates the cross product and dot product in a similar way:^{[40]}

This can be seen from the definitions of the cross product and dot product, as

with **n** a unit vector normal to both **a** and **b**. The relationship follows from these definitions and the Pythagorean trigonometric identity.

This can also be used to define the cross product. By rearranging the following equation is obtained

This can be considered as a condition on the cross product and so part of its definition, for example in seven dimensions.^{[41]}^{[42]}

A generalization of the Pythagorean theorem extending beyond the areas of squares on the three sides to similar figures was known by Hippocrates of Chios in the 5th century BC,^{[43]} and was included by Euclid in his *Elements*:^{[44]}

If one erects similar figures (see Euclidean geometry) with corresponding sides on the sides of a right triangle, then the sum of the areas of the ones on the two smaller sides equals the area of the one on the larger side.

This extension assumes that the sides of the original triangle are the corresponding sides of the three congruent figures (so the common ratios of sides between the similar figures are *a:b:c*).^{[45]} While Euclid's proof only applied to convex polygons, the theorem also applies to concave polygons and even to similar figures that have curved boundaries (but still with part of a figure's boundary being the side of the original triangle).^{[45]}

The basic idea behind this generalization is that the area of a plane figure is proportional to the square of any linear dimension, and in particular is proportional to the square of the length of any side. Thus, if similar figures with areas *A*, *B* and *C* are erected on sides with corresponding lengths *a*, *b* and *c* then:

Conversely, if we can prove that *A* + *B* = *C* for three similar figures without using the Pythagorean theorem, then we can work backwards to construct a proof of the theorem. For example, the starting center triangle can be replicated and used as a triangle *C* on its hypotenuse, and two similar right triangles (*A* and *B* ) constructed on the other two sides, formed by dividing the central triangle by its altitude. The sum of the areas of the two smaller triangles therefore is that of the third, thus *A* + *B* = *C* and reversing the above logic leads to the Pythagorean theorem a^{2} + b^{2} = c^{2}. (*See also *)

The Pythagorean theorem is a special case of the more general theorem relating the lengths of sides in any triangle, the law of cosines:^{[46]}

At any selected angle of a general triangle of sides *a, b, c*, inscribe an isosceles triangle such that the equal angles at its base θ are the same as the selected angle. Suppose the selected angle θ is opposite the side labeled *c*. Inscribing the isosceles triangle forms triangle *CAD* with angle θ opposite side *b* and with side *r* along *c*. A second triangle is formed with angle θ opposite side *a* and a side with length *s* along *c*, as shown in the figure. Thābit ibn Qurra stated that the sides of the three triangles were related as:^{[48]}^{[49]}

As the angle θ approaches π/2, the base of the isosceles triangle narrows, and lengths *r* and *s* overlap less and less. When θ = π/2, *ADB* becomes a right triangle, *r* + *s* = *c*, and the original Pythagorean theorem is regained.

One proof observes that triangle *ABC* has the same angles as triangle *CAD*, but in opposite order. (The two triangles share the angle at vertex A, both contain the angle θ, and so also have the same third angle by the triangle postulate.) Consequently, *ABC* is similar to the reflection of *CAD*, the triangle *DAC* in the lower panel. Taking the ratio of sides opposite and adjacent to θ,

Pappus's area theorem is a further generalization, that applies to triangles that are not right triangles, using parallelograms on the three sides in place of squares (squares are a special case, of course). The upper figure shows that for a scalene triangle, the area of the parallelogram on the longest side is the sum of the areas of the parallelograms on the other two sides, provided the parallelogram on the long side is constructed as indicated (the dimensions labeled with arrows are the same, and determine the sides of the bottom parallelogram). This replacement of squares with parallelograms bears a clear resemblance to the original Pythagoras' theorem, and was considered a generalization by Pappus of Alexandria in 4 AD^{[50]}^{[51]}

The lower figure shows the elements of the proof. Focus on the left side of the figure. The left green parallelogram has the same area as the left, blue portion of the bottom parallelogram because both have the same base *b* and height *h*. However, the left green parallelogram also has the same area as the left green parallelogram of the upper figure, because they have the same base (the upper left side of the triangle) and the same height normal to that side of the triangle. Repeating the argument for the right side of the figure, the bottom parallelogram has the same area as the sum of the two green parallelograms.

In terms of solid geometry, Pythagoras' theorem can be applied to three dimensions as follows. Consider a rectangular solid as shown in the figure. The length of diagonal *BD* is found from Pythagoras' theorem as:

where these three sides form a right triangle. Using horizontal diagonal *BD* and the vertical edge *AB*, the length of diagonal *AD* then is found by a second application of Pythagoras' theorem as:

This one-step formulation may be viewed as a generalization of Pythagoras' theorem to higher dimensions. However, this result is really just the repeated application of the original Pythagoras' theorem to a succession of right triangles in a sequence of orthogonal planes.

A substantial generalization of the Pythagorean theorem to three dimensions is de Gua's theorem, named for Jean Paul de Gua de Malves: If a tetrahedron has a right angle corner (like a corner of a cube), then the square of the area of the face opposite the right angle corner is the sum of the squares of the areas of the other three faces. This result can be generalized as in the "*n*-dimensional Pythagorean theorem":^{[52]}

This statement is illustrated in three dimensions by the tetrahedron in the figure. The "hypotenuse" is the base of the tetrahedron at the back of the figure, and the "legs" are the three sides emanating from the vertex in the foreground. As the depth of the base from the vertex increases, the area of the "legs" increases, while that of the base is fixed. The theorem suggests that when this depth is at the value creating a right vertex, the generalization of Pythagoras' theorem applies. In a different wording:^{[53]}

Given an *n*-rectangular *n*-dimensional simplex, the square of the (*n* − 1)-content of the facet opposing the right vertex will equal the sum of the squares of the (*n* − 1)-contents of the remaining facets.

The Pythagorean theorem can be generalized to inner product spaces,^{[54]} which are generalizations of the familiar 2-dimensional and 3-dimensional Euclidean spaces. For example, a function may be considered as a vector with infinitely many components in an inner product space, as in functional analysis.^{[55]}

The concept of length is replaced by the concept of the norm ||**v**|| of a vector **v**, defined as:^{[57]}

In an inner-product space, the **Pythagorean theorem** states that for any two orthogonal vectors **v** and **w** we have

Here the vectors **v** and **w** are akin to the sides of a right triangle with hypotenuse given by the vector sum **v** + **w**. This form of the Pythagorean theorem is a consequence of the properties of the inner product:

where the inner products of the cross terms are zero, because of orthogonality.

A further generalization of the Pythagorean theorem in an inner product space to non-orthogonal vectors is the *parallelogram law* :^{[57]}

which says that twice the sum of the squares of the lengths of the sides of a parallelogram is the sum of the squares of the lengths of the diagonals. Any norm that satisfies this equality is *ipso facto* a norm corresponding to an inner product.^{[57]}

The Pythagorean identity can be extended to sums of more than two orthogonal vectors. If **v**_{1}, **v**_{2}, ..., **v**_{n} are pairwise-orthogonal vectors in an inner-product space, then application of the Pythagorean theorem to successive pairs of these vectors (as described for 3-dimensions in the section on solid geometry) results in the equation^{[58]}

Another generalization of the Pythagorean theorem applies to Lebesgue-measurable sets of objects in any number of dimensions. Specifically, the square of the measure of an *m*-dimensional set of objects in one or more parallel *m*-dimensional flats in *n*-dimensional Euclidean space is equal to the sum of the squares of the measures of the orthogonal projections of the object(s) onto all *m*-dimensional coordinate subspaces.^{[59]}

Here two cases of non-Euclidean geometry are considered—spherical geometry and hyperbolic plane geometry; in each case, as in the Euclidean case for non-right triangles, the result replacing the Pythagorean theorem follows from the appropriate law of cosines.

However, the Pythagorean theorem remains true in hyperbolic geometry and elliptic geometry if the condition that the triangle be right is replaced with the condition that two of the angles sum to the third, say *A*+*B* = *C*. The sides are then related as follows: the sum of the areas of the circles with diameters *a* and *b* equals the area of the circle with diameter *c*.^{[63]}

For any right triangle on a sphere of radius *R* (for example, if γ in the figure is a right angle), with sides *a*, *b*, *c*, the relation between the sides takes the form:^{[64]}

This equation can be derived as a special case of the spherical law of cosines that applies to all spherical triangles:

By expressing the Maclaurin series for the cosine function as an asymptotic expansion with the remainder term in big O notation,

it can be shown that as the radius *R* approaches infinity and the arguments *a/R*, *b/R*, and *c/R* tend to zero, the spherical relation between the sides of a right triangle approaches the Euclidean form of the Pythagorean theorem. Substituting the asymptotic expansion for each of the cosines into the spherical relation for a right triangle yields

The constants *a*^{4}, *b*^{4}, and *c*^{4} have been absorbed into the big *O* remainder terms since they are independent of the radius *R*. This asymptotic relationship can be further simplified by multiplying out the bracketed quantities, cancelling the ones, multiplying through by −2, and collecting all the error terms together:

After multiplying through by *R*^{2}, the Euclidean Pythagorean relationship *c*^{2} = *a*^{2} + *b*^{2} is recovered in the limit as the radius *R* approaches infinity (since the remainder term tends to zero):

For small right triangles (*a*, *b* << *R*), the cosines can be eliminated to avoid loss of significance, giving

In a hyperbolic space with uniform curvature −1/*R*^{2}, for a right triangle with legs *a*, *b*, and hypotenuse *c*, the relation between the sides takes the form:^{[65]}

where cosh is the hyperbolic cosine. This formula is a special form of the hyperbolic law of cosines that applies to all hyperbolic triangles:^{[66]}

By using the Maclaurin series for the hyperbolic cosine, cosh *x* ≈ 1 + *x*^{2}/2, it can be shown that as a hyperbolic triangle becomes very small (that is, as *a*, *b*, and *c* all approach zero), the hyperbolic relation for a right triangle approaches the form of Pythagoras' theorem.

For small right triangles (*a*, *b* << *R*), the hyperbolic cosines can be eliminated to avoid loss of significance, giving

For any uniform curvature *K* (positive, zero, or negative), in very small right triangles (|*K*|*a*^{2}, |*K*|*b*^{2} << 1) with hypotenuse *c*, it can be shown that

On an infinitesimal level, in three dimensional space, Pythagoras' theorem describes the distance between two infinitesimally separated points as:

with *ds* the element of distance and (*dx*, *dy*, *dz*) the components of the vector separating the two points. Such a space is called a Euclidean space. However, in Riemannian geometry, a generalization of this expression useful for general coordinates (not just Cartesian) and general spaces (not just Euclidean) takes the form:^{[67]}

which is called the metric tensor. (Sometimes, by abuse of language, the same term is applied to the set of coefficients *g*_{ij}.) It may be a function of position, and often describes curved space. A simple example is Euclidean (flat) space expressed in curvilinear coordinates. For example, in polar coordinates:

There is debate whether the Pythagorean theorem was discovered once, or many times in many places, and the date of first discovery is uncertain, as is the date of the first proof. Historians of Mesopotamian mathematics have concluded that the Pythagorean rule was in widespread use during the Old Babylonian period (20th to 16th centuries BC), over a thousand years before Pythagoras was born.^{[69]}^{[70]}^{[71]}^{[72]} The history of the theorem can be divided into four parts: knowledge of Pythagorean triples, knowledge of the relationship among the sides of a right triangle, knowledge of the relationships among adjacent angles, and proofs of the theorem within some deductive system.

Written between 2000 and 1786 BC, the Middle Kingdom Egyptian *Berlin Papyrus 6619* includes a problem whose solution is the Pythagorean triple 6:8:10, but the problem does not mention a triangle. The Mesopotamian tablet *Plimpton 322*, written between 1790 and 1750 BC during the reign of Hammurabi the Great, contains many entries closely related to Pythagorean triples.

In India, the *Baudhayana Shulba Sutra*, the dates of which are given variously as between the 8th and 5th century BC,^{[73]} contains a list of Pythagorean triples and a statement of the Pythagorean theorem, both in the special case of the isosceles right triangle and in the general case, as does the *Apastamba Shulba Sutra* (c. 600 BC). Van der Waerden believed that this material "was certainly based on earlier traditions". Carl Boyer states that the Pythagorean theorem in the *Śulba-sũtram* may have been influenced by ancient Mesopotamian math, but there is no conclusive evidence in favor or opposition of this possibility.^{[74]}

Proclus, writing in the fifth century AD, states two arithmetic rules, "one of them attributed to Plato, the other to Pythagoras",^{[75]} for generating special Pythagorean triples. The rule attributed to Pythagoras (c. 570 – c. 495 BC) starts from an odd number and produces a triple with leg and hypotenuse differing by one unit; the rule attributed to Plato (428/427 or 424/423 – 348/347 BC) starts from an even number and produces a triple with leg and hypotenuse differing by two units. According to Thomas L. Heath (1861–1940), no specific attribution of the theorem to Pythagoras exists in the surviving Greek literature from the five centuries after Pythagoras lived.^{[76]} However, when authors such as Plutarch and Cicero attributed the theorem to Pythagoras, they did so in a way which suggests that the attribution was widely known and undoubted.^{[77]}^{[78]} Classicist Kurt von Fritz wrote, "Whether this formula is rightly attributed to Pythagoras personally, but one can safely assume that it belongs to the very oldest period of Pythagorean mathematics."^{[36]} Around 300 BC, in Euclid's *Elements*, the oldest extant axiomatic proof of the theorem is presented.^{[79]}

With contents known much earlier, but in surviving texts dating from roughly the 1st century BC, the Chinese text *Zhoubi Suanjing* (周髀算经), () gives a reasoning for the Pythagorean theorem for the (3, 4, 5) triangle—in China it is called the "**Gougu theorem**" (勾股定理).^{[80]}^{[81]} During the Han Dynasty (202 BC to 220 AD), Pythagorean triples appear in *The Nine Chapters on the Mathematical Art*,^{[82]} together with a mention of right triangles.^{[83]} Some believe the theorem arose first in China,^{[84]} where it is alternatively known as the "**Shang Gao theorem**" (商高定理),^{[85]} named after the Duke of Zhou's astronomer and mathematician, whose reasoning composed most of what was in the *Zhoubi Suanjing*.^{[86]}

*The Arithmetical Classic of the Gnomon and the Circular Paths of Heaven*