The Pythagorean theorem is a special case of the more general theorem relating the lengths of sides in any triangle, the law of cosines:[ 1]
a
2
+
b
2
−
2
a
b
cos
(
θ
)
=
c
2
{\displaystyle a^{2}+b^{2}-2ab\cos(\theta )=c^{2}}
where
θ
{\displaystyle \theta }
is the angle between sides
a
{\displaystyle a}
and
b
{\displaystyle b}
.
This formula had better agree with the Pythagorean Theorem when
θ
=
90
∘
{\displaystyle \theta =90^{\circ }}
.
So try it...
When
θ
=
90
∘
{\displaystyle \theta =90^{\circ }}
,
cos
(
θ
)
=
cos
(
90
∘
)
=
0
{\displaystyle \cos(\theta )=\cos(90^{\circ })=0}
The
−
2
a
b
cos
(
θ
)
=
0
{\displaystyle -2ab\cos(\theta )=0}
and the formula reduces to the usual Pythagorean theorem.
For any triangle with angles
A
,
B
,
C
{\displaystyle A,B,C}
and corresponding opposite side lengths
a
,
b
,
c
{\displaystyle a,b,c}
, the Law of Cosines states that
a
2
=
b
2
+
c
2
−
2
b
c
⋅
cos
(
A
)
{\displaystyle a^{2}=b^{2}+c^{2}-2bc\cdot \cos(A)}
b
2
=
a
2
+
c
2
−
2
a
c
⋅
cos
(
B
)
{\displaystyle b^{2}=a^{2}+c^{2}-2ac\cdot \cos(B)}
c
2
=
a
2
+
b
2
−
2
a
b
⋅
cos
(
C
)
{\displaystyle c^{2}=a^{2}+b^{2}-2ab\cdot \cos(C)}
Dropping a perpendicular
O
C
{\displaystyle OC}
from vertex
C
{\displaystyle C}
to intersect
A
B
{\displaystyle AB}
(or
A
B
{\displaystyle AB}
extended) at
O
{\displaystyle O}
splits this triangle into two right-angled triangles
A
O
C
{\displaystyle AOC}
and
B
O
C
{\displaystyle BOC}
, with altitude
h
{\displaystyle h}
from side
c
{\displaystyle c}
.
First we will find the lengths of the other two sides of triangle
A
O
C
{\displaystyle AOC}
in terms of known quantities, using triangle
B
O
C
{\displaystyle BOC}
.
h
=
a
sin
(
B
)
{\displaystyle h=a\sin(B)}
Side
c
{\displaystyle c}
is split into two segments, with total length
c
{\displaystyle c}
.
O
B
¯
{\displaystyle {\overline {OB}}}
has length
B
C
¯
cos
(
B
)
=
a
cos
(
B
)
{\displaystyle {\overline {BC}}\cos(B)=a\cos(B)}
A
O
¯
=
A
B
¯
−
O
B
¯
{\displaystyle {\overline {AO}}={\overline {AB}}-{\overline {OB}}}
has length
c
−
a
cos
(
B
)
{\displaystyle c-a\cos(B)}
Now we can use the Pythagorean Theorem to find
b
{\displaystyle b}
, since
b
2
=
A
O
¯
2
+
h
2
{\displaystyle b^{2}={\overline {AO}}^{2}+h^{2}}
.
b
2
{\displaystyle b^{2}}
=
(
c
−
a
cos
(
B
)
)
2
+
a
2
sin
2
(
B
)
{\displaystyle ={\bigl (}c-a\cos(B){\bigr )}^{2}+a^{2}\sin ^{2}(B)}
=
c
2
−
2
a
c
cos
(
B
)
+
a
2
cos
2
(
B
)
+
a
2
sin
2
(
B
)
{\displaystyle =c^{2}-2ac\cos(B)+a^{2}\cos ^{2}(B)+a^{2}\sin ^{2}(B)}
=
a
2
+
c
2
−
2
a
c
cos
(
B
)
{\displaystyle =a^{2}+c^{2}-2ac\cos(B)}
The corresponding expressions for
a
{\displaystyle a}
and
c
{\displaystyle c}
can be proved similarly.
The formula can be rearranged:
cos
(
C
)
=
a
2
+
b
2
−
c
2
2
a
b
{\displaystyle \cos(C)={\frac {a^{2}+b^{2}-c^{2}}{2ab}}}
and similarly for
c
o
s
(
A
)
{\displaystyle cos(A)}
and
c
o
s
(
B
)
{\displaystyle cos(B)}
.
This formula can be used to find the third side of a triangle if the other two sides and the angle between them are known. The rearranged formula can be used to find the angles of a triangle if all three sides are known. See Solving Triangles Given SAS .