Law of Cosines

Introduction

The Pythagorean theorem relates the sides of a right triangle: a2+b2=c2 a squared plus b squared equals c squared. But what about triangles that aren't right triangles? The Law of Cosines answers this question, providing a generalization that works for any triangle.

The Law of Cosines connects the three sides of a triangle to one of its angles. It serves two main purposes: computing an unknown side when two sides and the included angle are known, and computing angles when all three sides are known.

This theorem, known since antiquity, appears in the works of Euclid and was refined by later mathematicians. It remains fundamental in surveying, navigation, physics, and any field requiring precise distance calculations.

Statement of the Law

Consider a triangle with sides a a, b b, c c opposite to angles ∠A angle A, B B, C C respectively. The Law of Cosines states:

c2=a2+b2−2⁢a⁢b⁢cos⁡C c squared equals a squared plus b squared minus 2 a b cosine C

By symmetry, analogous formulas hold for the other sides:

a2=b2+c2−2⁢b⁢c⁢cos⁡A a squared equals b squared plus c squared minus 2 b c cosine A

b2=a2+c2−2⁢a⁢c⁢cos⁡B b squared equals a squared plus c squared minus 2 a c cosine B

Each formula relates one side to the other two sides and the angle opposite to it. The term -2⁢a⁢b⁢cos⁡C negative 2 a b cosine C is the correction that accounts for the triangle not being a right triangle.

Connection to Pythagorean Theorem

When C=90 equals 90°, we have cos⁡C=0 cosine C equals 0, so the Law of Cosines reduces to:

c2=a2+b2−2⁢a⁢b⁡(0)=a2+b2 c squared equals a squared plus b squared minus 2 a b of 0 equals a squared plus b squared

This is precisely the Pythagorean theorem! The Law of Cosines is thus a proper generalization that includes the Pythagorean theorem as a special case.

Geometric Proof

Place the triangle in a coordinate system with vertex C C at the origin and side b along the positive x x-axis. Then:

Vertex C C is at (0 0, 0 0)

Vertex A A is at (b,0) open paren b comma 0 close paren

Vertex B B is at (a⁢cos⁡C,a⁢sin⁡C) open paren a cosine C comma a sine C close paren

The distance from A to B is side c. Using the distance formula:

c2=(a⁢cos⁡C−b)2+(a⁢sin⁡C−0)2 c squared equals open paren a cosine C minus b close paren squared plus open paren a sine C minus 0 close paren squared

Expanding:

c2=a2⁢cos2⁡C−2⁢a⁢b⁢cos⁡C+b2+a2⁢sin2⁡C c squared equals a squared cosine squared C minus 2 a b cosine C plus b squared plus a squared sine squared C

c2=a2⁢(cos2⁡C+sin2⁡C)+b2−2⁢a⁢b⁢cos⁡C c squared equals a squared times open paren cosine squared C plus sine squared C close paren plus b squared minus 2 a b cosine C

Since cos2⁡C+sin2⁡C=1 cosine squared C plus sine squared C equals 1 we obtain:

c2=a2+b2−2⁢a⁢b⁢cos⁡C c squared equals a squared plus b squared minus 2 a b cosine C

Vector Proof

Let vectors a and b represent two sides of the triangle emanating from vertex C C, with |a|=a the absolute value of a equals a and |b|=b the absolute value of b equals b. The third side is c=a-b c equals a minus b or c=b-a c equals b minus a, depending on orientation.

Computing the squared length:

|c|2=|a-b|2=(a-b)⋅(a-b)=a⋅a-2⁢a⋅b+b⋅b=|a|2+|b|2-2⁢|a|⁢|b|⁢cos⁡C the absolute value of c squared equals the absolute value of a minus b squared equals open paren a minus b close paren times open paren a minus b close paren equals a times a minus 2 a times b plus b times b equals the absolute value of a squared plus the absolute value of b squared minus 2 times the absolute value of a times the absolute value of b times cosine C

where C C is the angle between vectors a and b, giving us:

c2=a2+b2−2⁢a⁢b⁢cos⁡C c squared equals a squared plus b squared minus 2 a b cosine C

This elegant vector proof reveals the Law of Cosines as a direct consequence of the dot product definition.

Solving for Angles

When all three sides are known, we can solve for any angle. Rearranging the formula:

cos⁡C=a2+b2−c22⁢a⁢b cosine C equals the fraction with numerator a squared plus b squared minus c squared and denominator 2 a b

Similarly for the other angles:

cos⁡A=b2+c2−a22⁢b⁢c cosine A equals the fraction with numerator b squared plus c squared minus a squared and denominator 2 b c

cos⁡B=a2+c2−b22⁢a⁢c cosine B equals the fraction with numerator a squared plus c squared minus b squared and denominator 2 a c

The angle is then found using the inverse cosine function. Note that since 0° 0 degrees < angle < 180° 180 degrees in any triangle, the inverse cosine gives the unique answer.

Determining Triangle Type

The sign of cos⁡C cosine C reveals the type of angle C C:

If a2+b2>c2 a squared plus b squared is greater than c squared, then cos⁡C>0 cosine C is greater than 0, so C Cis acute

If a2+b2=c2 a squared plus b squared equals c squared, then cos⁡C=0 cosine C equals 0, so C=90° C equals 90 degrees (right angle)

If a2+b2<c2 a squared plus b squared is less than c squared, then cos⁡C<0 cosine C is less than 0, so C C is obtuse

This generalizes the Pythagorean test for right triangles.

Worked Examples

Example 1: Finding a Side (SAS)

In triangle △A⁢B⁢C white up pointing triangle A B C, a=5 a equals 5, b=7 b equals 7, and C=60 C equals 60°. Find c c.

Using the Law of Cosines:

c2=a2+b2−2⁢a⁢b⁢cos⁡C=25+49−2⁢(5)⁢(7)⁢cos⁡60° c squared equals a squared plus b squared minus 2 a b cosine C equals 25 plus 49 minus 2 times 5 times 7 times cosine 60 degrees

c2=74−70⋅12=74−35=39 c squared equals 74 minus 70 times one half equals 74 minus 35 equals 39

c=39≈6.24 c equals the square root of 39 almost equals 6.24

Example 2: Finding an Angle (SSS)

In a triangle with sides a=8 a equals 8, b=6,c=10 b equals 6 comma c equals 10, find angle C C.

Using the formula for cos⁡C cosine C:

cos⁡C=a2+b2−c22⁢a⁢b=64+36−1002⁢(8)⁢(6)=096=0 cosine C equals the fraction with numerator a squared plus b squared minus c squared and denominator 2 a b equals the fraction with numerator 64 plus 36 minus 100 and denominator 2 times 8 times 6 equals 0 over 96 equals 0

Since cos⁡C=0 cosine C equals 0, we have C=90 C equals 90°. This is a right triangle (a 6 6-8 8-10 10 triangle, which is a 3 3-4 4-5 5 triangle scaled by 2 2).

Applications

Navigation and Surveying

Surveyors use the Law of Cosines to determine distances that cannot be measured directly. Given two accessible points and the angle between sightlines to an inaccessible third point, the distance to that point can be calculated.

Physics: Force Addition

When two forces act at an angle, their resultant magnitude follows from the Law of Cosines. If forces of magnitude F1 F sub 1 and F2 F sub 2 act at angle θ theta, the resultant has magnitude:

R=F12+F22+2⁢F1⁢F2⁢cos⁡θ R equals the square root of F sub 1 squared plus F sub 2 squared plus 2 F sub 1 F sub 2 cosine theta

Note the positive sign because we measure θ theta from one force to the other, not the angle opposite R R in the force triangle.

Computer Graphics

In 3 3D graphics and game development, the Law of Cosines helps compute distances and angles between objects, essential for collision detection, lighting calculations, and camera positioning.

Relationship to Law of Sines

The Law of Cosines and Law of Sines are complementary tools for solving triangles:

Law of Cosines: Best for SAS (two sides and included angle) and SSS (three sides) problems

Law of Sines: Best for AAS, ASA (two angles and a side) and SSA (two sides and non-included angle) problems

When solving triangles, choose the appropriate law based on which information is given. Often, one uses the Law of Cosines first to find a missing side, then the Law of Sines to find remaining angles.

Generalization: Spherical Law of Cosines

On a sphere, the planar Law of Cosines generalizes to the spherical law of cosines. For a spherical triangle with sides a a, b b, c c(measured as angles from the sphere's center) and angle C C opposite side c c:

cos⁡c=cos⁡(a)⁢cos⁡b+sin⁡(a)⁢sin⁡(b)⁢cos⁡C cosine c equals cosine a cosine b plus sine a sine b cosine C

This formula is essential in navigation and astronomy for computing distances on Earth's surface.

Summary

The Law of Cosines states c2=a2+b2-2⁢a⁢b⁢cos⁡C c squared equals a squared plus b squared minus 2 a b cosine C, relating the three sides of a triangle to one angle. It generalizes the Pythagorean theorem (which is the special case when C=90 C equals 90°).

The law can be proved geometrically using coordinates or elegantly using the vector dot product. Rearranging gives cos⁡C=a2+b2-c22⁢a⁢b cosine C equals the fraction with numerator a squared plus b squared minus c squared and denominator 2 a b, allowing computation of angles when all sides are known.

The sign of the cosine reveals whether an angle is acute (positive), right (zero), or obtuse (negative). This extends the Pythagorean criterion a2+b2=c2 a squared plus b squared equals c squared for right triangles.

Applications span surveying, navigation, physics (force composition), and computer graphics. Together with the Law of Sines, it provides a complete toolkit for solving any triangle given sufficient information.