# Is being a right triangle both necessary and sufficient for the Pythagorean Theorem to hold?

I recently encountered a Stack Overflow question (since closed) in which the OP was testing for whether a triangle was right by whether or not it "met" the criteria of the Pythagorean Theorem (i.e. whether or not the square of the hypotenuse is equal to the square of the two sides). The code was to this effect:

public void Test(int a, int b, int c) {
if ((c * c) == ((a * a) + (b * b)) {
System.out.println("This is a right triangle");
}
else {
System.out.println("This is not a right triangle");
}
}


(There are obviously some other problems with this code, like the fact that it doesn't validate the input to make sure that the inputs are positive and the fact that it only accepts integers).

The question was asking about something completely different in the code and never directly addressed the test, but I got to thinking: is this a valid test for whether a triangle is a right triangle?

Obviously, the Pythagorean Theorem states that, for all right triangles, $a^2 + b^2 = c^2$ (where $a$ and $b$ are sides and $c$ is the hypotenuse). This will hold for all right triangles, so being a right triangle is a sufficient condition for the Pythagorean Theorem to hold.

Is it also a necessary condition? I.e. if $c^2 = a^2 + b^2$ for some arbitrary triangle, is the triangle necessarily a right triangle? Or are there counterexamples?

• For what it is worth, I think the biggest problem with the code is that it is liable to overflow in many (most?) languages. – PJTraill Jul 5 '17 at 9:20
• I assume you're asking about Euclidean Geometry... – user121330 Jul 5 '17 at 22:10
• @user121330 Yes, I do tag Euclidean geometry. – EJoshuaS Jul 5 '17 at 22:11
• Many great questions to a specific special case of this theorem (from some you can deduce the general case) are given in this old matheducators.se post: matheducators.stackexchange.com/q/9847/5778 – Vincent Jul 6 '17 at 9:12

Yep, the converse of the Pythagorean Theorem is also true. It can be proved using the law of cosines:

Assume $a,b,c$ are the sides of a triangle and they satisfy $a^2 + b^2 = c^2$. Let $\angle ACB = \gamma$. By the law of cosines,

$$c^2 = a^2 + b^2 - 2ab\cos\gamma .$$

Since $a,b > 0$, we must have $\cos\gamma = 0$. Since $0 < \gamma < 180^\circ$, we must have $\gamma = 90^\circ$. So $\Delta ABC$ is a right triangle.

• This nicely demonstrates that the Pythagorean Theorem is merely a special case of the law of cosines, when $\gamma = 90^\circ$, and the whole $2ab\cos\gamma$ term works out to $0$ – Alexander Jul 5 '17 at 1:04
• Isn't all of trigonometry already dependent on the Pythagorean inverse, making this answer a begging the question solution. Pulling the Law of Cosines out of the hat for this is a real proof smell to me – Pieter Geerkens Jul 6 '17 at 8:48

Suppose that $a^2 + b^2 = c^2$ is a necessary condition to be a right triangle.

Corollary: $a^2 + b^2 = c^2$ is a sufficient condition to be a right triangle.

Proof: Suppose you're given a particular triangle whose side lengths satisfy $a^2 + b^2 = c^2$.

Construct a right triangle whose two sides adjacent to the angle are of length $a$ and $b$ (e.g. start with the right angle, and mark off the two sides to have the appropriate length). By the supposition, it follows that the third side of the right triangle has length $c$.

By the side-side-side congruence theorem, the original triangle is congruent to the right triangle, and thus the original triangle is a right triangle.

• I like this answer the best because it uses the lowest level of mathematics of all of the answers currently offered, and is thus understandable by the widest audience. – Dan Henderson Jul 4 '17 at 17:51
• This is both simpler and clearer than the accepted answer. Also depends on less stuff. – Jeffrey Jul 5 '17 at 18:33
• Earlier I wrote a question about this type of proof: math.stackexchange.com/q/1500691/101420. More answers are still welcome! – Vincent Jul 5 '17 at 21:53
• This assumes it is possible to construct such a triangle. It may not be. For example $a=b=c=0$ satisfies $a^2 + b^2 = c^2$. But that is not a right triangle and if you attempt to use this proof, you will get stuck at the construction step. Similar for negative values, and who knows, absent a proof, maybe for some positive values too. – David Schwartz Jul 6 '17 at 1:24
• @DavidSchwartz: The implication is vacuously true for triangles with side lengths impossible for a triangle to have (and as an aside, I imagine the proof would work as is for zero and negative values anyways, if we generalized appropriately to triangles with oriented or degenerate edges). Also, I am content to assume both that the setting is Euclidean geometry and that the reader is familiar with its most basic notions: I am already of the opinion the parenthetical is borderline too much detail, and showing how to cite the congruence and incidence axioms is way beyond the scope of this post. – Hurkyl Jul 6 '17 at 1:51

The Pythagorean theorem gives a necessary and sufficient characterization of being a right triangle. In other words, when $a$, $b$, and $c$ are the side lengths of a triangle, $a^2 + b^2 = c^2$ is equivalent to the angle opposite the $c$-side being a right angle. This follows from the law of cosines, which states

$$c^2 = a^2 + b^2 - 2 ab \cos C$$

where $C$ is the angle opposite the $c$-side, for any triangle with side lengths $a$, $b$, and $c$. We only get $c^2 = a^2 + b^2$ when $\cos C = 0$, or when $C = 90^{\circ}$.

It is also interesting to note that this theorem (both the necessary and sufficient parts) are proved in Euclid's Elements via geometric methods.

The law of cosines states that $$c^2=a^2+b^2-2ab\cos(C),$$ where $C$ is the angle opposite the side of length $c$. When does $\cos(C)=0$?

Let $ABC$ be a non-degenerate triangle with side lengths fulfilling $BC^2+AC^2=AB^2$. Let $\ell$ be the line perpendicular to $BC$ and going through $C$. Let $A'$ and $A''$ be the two distinct points where the circle around $C$ of radius $AC$ intersects $\ell$. Then $A'BC$ and $A''BC$ are right triangles. By Pythagoras, $A'B^2=BC^2+A'C^2=BC^2+AC^2=AB^2$ and likewise $A''B^2=AB^2$. This means that the circle around $B$ of radius $AB$ and the circle around $C$ of radius $AC$ intersect in $A$, $A'$, and $A''$. As there are in fact only two points of intersection and as certainly $A'\ne A''$, we conclude that $A=A'$ or $A=A''$. In both cases, $ABC$ is a right triangle.

Yes, and this goes back to Euclid. Euclid I.47 is "In right-angled triangles the square on the side opposite the right angle equals the sum of the squares on the sides containing the right angle." Euclid I.48 is the converse, "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."

As other answers have pointed out, this is indeed correct. Although you could nitpick that it isn't correct outside of Euclidean geometry. That is, you could have "right triangles" on a sphere or other non-planar surfaces where the Pythagorean theorem wouldn't hold, and some non-right triangles where it does.

I wonder whether it would still hold true in non-Euclidean geometry if you additionally impose the sum of angles to be 180 degrees.

• That's true and a good point (although, for what it's worth, I did tag the question with Euclidean geometry), – EJoshuaS Jul 4 '17 at 14:06
• Euclidean geometry is implicit. If you want to ask about other geometries, that's a new question, not an answer. – David Richerby Jul 4 '17 at 14:51
• In non-Euclidean Geometry, triangles never have a sum of angles equal to 180 degrees. – Mark S. Jul 5 '17 at 0:22
• @MarkS. Sure they do. Euclidean Geometry is just a special case. – user121330 Jul 5 '17 at 23:00
• @user121330 I think you're thinking of absolute geometry. As mentioned on wikipedia, "non-Euclidean geometry" refers to two types of altered versions of geometry, and netiher can have a triangle whose angles add up to $180^{\circ}$. – Mark S. Jul 6 '17 at 0:30