Mathematics

Law of Cosines: Definition, Formula & Example

The Law of Cosines relates the three sides of a triangle to one of its angles. For sides a, b, and c opposite angles A, B, and C, the formula c² = a² + b² − 2ab cosC finds side c when sides a and b and their included angle C are known. The formula can also be rearranged to find an angle when all three side lengths are known: C = cos⁻¹[(a² + b² − c²)/(2ab)]. Unlike the Pythagorean theorem, the Law of Cosines works with acute, right, and obtuse triangles. In fact, when C = 90°, cos90° = 0 and the formula becomes c² = a² + b². This makes the Law of Cosines a generalization of the Pythagorean theorem and a fundamental method for solving SAS and SSS triangles.

What Is the Law of Cosines?

For a triangle with sides:

a, b, c

opposite angles:

A, B, C

the Law of Cosines can be written in three corresponding forms:

a² = b² + c² − 2bc cosA

b² = a² + c² − 2ac cosB

c² = a² + b² − 2ab cosC

Each formula pairs one side with its opposite angle.

If you are finding side c, use angle C and the other two sides a and b.

If you are finding angle C, use all three sides and rearrange the third equation.

When to Use the Law of Cosines

The Law of Cosines is especially useful for two triangle data patterns.

The first is:

SAS — two sides and their included angle

In that case, the formula finds the third side.

The second is:

SSS — all three sides

In that case, a rearranged formula finds an angle.

These cases complement the Law of Sines, which is often more convenient when a known side-angle opposite pair is available.

Law of Cosines for a Missing Side

Suppose sides a and b and included angle C are known.

Use:

c² = a² + b² − 2ab cosC

Then:

c = √(a² + b² − 2ab cosC)

The nonnegative root is used because c is a length.

Basic SAS Example

Suppose:

a = 7

b = 10

C = 60°

Then:

c² = 7² + 10² − 2(7)(10)cos60°

Since:

cos60° = 1/2

we get:

c² = 49 + 100 − 70

= 79

Therefore:

c = √79

Approximately:

c ≈ 8.89

Check the Side Length

A valid triangle must satisfy the triangle inequality.

For:

7, 10, √79

we have approximately:

7 + 8.89 > 10

7 + 10 > 8.89

10 + 8.89 > 7

All conditions hold.

A useful rough check is that the third side must lie between:

|a − b|

and:

a + b

For this example:

3 < c < 17

and:

8.89

fits that interval.

Law of Cosines for an Angle

Starting with:

c² = a² + b² − 2ab cosC

move the cosine term:

2ab cosC = a² + b² − c²

Divide:

cosC = (a² + b² − c²)/(2ab)

Therefore:

C = cos⁻¹[(a² + b² − c²)/(2ab)]

The inverse cosine converts the calculated ratio into an angle.

Basic SSS Example

Suppose:

a = 5

b = 7

c = 8

Then:

cosC = (5² + 7² − 8²)/(2·5·7)

= (25 + 49 − 64)/70

= 10/70

= 1/7

Therefore:

C = cos⁻¹(1/7)

Approximately:

C ≈ 81.79°

The Inverse Trigonometric Functions relationship turns the cosine value into the required angle.

Matching Sides With Opposite Angles

Correct correspondence is essential.

In triangle ABC:

side a is opposite angle A

side b is opposite angle B

side c is opposite angle C

Therefore the formula containing:

cosC

must have:

alone on the opposite side.

A common setup error is using an angle with the wrong opposite side.

Three Equivalent Forms

For angle A:

a² = b² + c² − 2bc cosA

For angle B:

b² = a² + c² − 2ac cosB

For angle C:

c² = a² + b² − 2ab cosC

There is no mathematical preference among these forms.

Choose the one corresponding to the unknown side or angle.

Law of Cosines and the Pythagorean Theorem

If:

C = 90°

then:

cos90° = 0

So:

c² = a² + b² − 2ab(0)

Therefore:

c² = a² + b²

This is exactly the Pythagorean Theorem.

The Law of Cosines is therefore a general extension of right-triangle geometry.

Right Triangle Example

Suppose:

a = 6

b = 8

C = 90°

Then:

c² = 36 + 64 − 0

= 100

Therefore:

c = 10

This produces the familiar:

6-8-10

right triangle.

Acute Included Angles

If:

0° < C < 90°

then:

cosC > 0

So the term:

−2ab cosC

is negative.

Therefore:

c² < a² + b²

The side opposite an acute included angle is shorter than the corresponding Pythagorean comparison.

Obtuse Included Angles

If:

90° < C < 180°

then:

cosC < 0

Therefore:

−2ab cosC

becomes positive.

So:

c² > a² + b²

The side opposite an obtuse angle is longer than it would be in the corresponding right-triangle case.

Classifying a Triangle With Side Lengths

Let c be the longest side.

Compare:

with:

a² + b²

If:

c² < a² + b²

the triangle is acute.

If:

c² = a² + b²

the triangle is right.

If:

c² > a² + b²

the triangle is obtuse.

This classification follows directly from the sign of cosine in the Law of Cosines.

Acute Triangle Example

Sides:

5, 6, 7

The longest side is:

7

Compare:

7² = 49

with:

5² + 6² = 61

Since:

49 < 61

the triangle is acute.

Right Triangle Example From Sides

Sides:

5, 12, 13

Compare:

13² = 169

with:

5² + 12² = 25 + 144 = 169

Therefore the triangle is right.

The angle opposite side 13 is:

90°

Obtuse Triangle Example

Sides:

4, 5, 7

Compare:

7² = 49

with:

4² + 5² = 41

Since:

49 > 41

the triangle is obtuse.

The angle opposite side 7 is greater than 90°.

Why SAS Determines a Unique Triangle

Suppose two side lengths:

a

and:

b

and their included angle C are known.

The Law of Cosines determines:

c² = a² + b² − 2ab cosC

Therefore c is fixed.

Once all three sides are known, the triangle is fixed up to reflection.

This gives an algebraic explanation for the SAS criterion used with Congruent Triangles.

Why SSS Determines the Angles

If all three sides are known:

a, b, c

then:

cosA = (b² + c² − a²)/(2bc)

cosB = (a² + c² − b²)/(2ac)

cosC = (a² + b² − c²)/(2ab)

Thus all three angles are determined.

Only two need to be calculated independently because the Interior Angles satisfy:

A + B + C = 180°

Finding All Three Angles

Suppose:

a = 5

b = 7

c = 8

We already found:

C ≈ 81.79°

Find A:

cosA = (7² + 8² − 5²)/(2·7·8)

= (49 + 64 − 25)/112

= 88/112

= 11/14

Therefore:

A ≈ cos⁻¹(11/14)

≈ 38.21°

Then:

B = 180° − A − C

≈ 180° − 38.21° − 81.79°

Therefore:

B ≈ 60.00°

Use the Angle Sum for the Last Angle

Once two angles are known:

third angle = 180° − first angle − second angle

This is generally more efficient than applying the Law of Cosines three times.

It also provides a check on rounding.

If two angles were rounded early, retain enough precision before calculating the final angle.

Law of Cosines Versus Law of Sines

The Law of Cosines is especially strong for:

SAS

and:

SSS

The Law of Sines is especially useful when a known opposite side-angle pair exists, including:

ASA

AAS

and some:

SSA

problems.

Choosing the formula based on the given information reduces unnecessary algebra.

SAS Versus SSA

SAS means two sides and the angle between them.

This determines one triangle.

SSA means two sides and an angle not between them.

SSA can sometimes produce:

no triangle

one triangle

or:

two triangles

This is the ambiguous case usually handled with the Law of Sines.

Do not treat a nonincluded angle as though it were the included angle in:

c² = a² + b² − 2ab cosC

Law of Cosines and Heron Formula

Once all three side lengths are known, Heron Formula can calculate area:

s = (a + b + c)/2

A = √[s(s − a)(s − b)(s − c)]

This is useful when the Law of Cosines first determines a missing third side.

However, if two sides and their included angle are already known, the area formula:

A = ab sinC/2

is usually more direct.

SAS Area Example

Suppose:

a = 7

b = 10

C = 60°

The Law of Cosines gave:

c = √79

The triangle’s area can be found directly:

A = 7(10)sin60°/2

= 35√3/2

Approximately:

A ≈ 30.31

Heron’s formula using sides:

7, 10, √79

would produce the same area.

Law of Cosines and Cosine

The formula explicitly uses the Cosine of the included angle.

Cosine controls how much two side directions align.

For:

C = 0°

cosC approaches:

1

and the opposite side approaches:

|a − b|

For:

C = 180°

cosC approaches:

−1

and the opposite side approaches:

a + b

These are the limiting degenerate cases of the triangle inequality.

Deriving the Law of Cosines With Coordinates

Place one triangle vertex at:

A = (0, 0)

and another at:

B = (a, 0)

Let the third point C be distance b from A at angle C? To avoid symbol conflict, let the included angle at A be θ.

Then coordinates of C are:

(b cosθ, b sinθ)

The distance from B to C is:

c² = (b cosθ − a)² + (b sinθ)²

Expand:

c² = b²cos²θ − 2ab cosθ + a² + b²sin²θ

Use:

sin²θ + cos²θ = 1

Therefore:

c² = a² + b² − 2ab cosθ

This is the Law of Cosines.

Coordinate Geometry Application

Suppose triangle vertices are:

A = (0, 0)

B = (6, 0)

C = (2, 5)

Use the Distance Formula to calculate:

AB = 6

AC = √29

BC = √41

If angle A is required:

cosA = (AB² + AC² − BC²)/(2·AB·AC)

Substitute:

cosA = (36 + 29 − 41)/(12√29)

= 24/(12√29)

Therefore:

cosA = 2/√29

and:

A = cos⁻¹(2/√29)

Angle Between Two Segments

Coordinate geometry can also form two vectors from the same vertex.

For:

u = B − A

and:

v = C − A

the side lengths:

|u|

|v|

and:

|uv|

form a triangle.

The Law of Cosines then finds the included angle between the two segments.

This relationship is closely connected to the vector dot product.

Law of Cosines and Dot Product

The Dot Product identity is:

u·v = |u||v|cosθ

The Law of Cosines can be derived from:

|uv

Expanding the squared magnitude gives:

|uv|² = |u|² + |v|² − 2u·v

Substitute the dot product:

= |u|² + |v|² − 2|u||v|cosθ

This is exactly the Law of Cosines in vector form.

Law of Cosines and Chord Length

A chord and two radii form an isosceles triangle.

If the circle radius is r and central angle is θ, the Chord Length c satisfies:

c² = r² + r² − 2r²cosθ

Therefore:

c² = 2r²(1 − cosθ)

and:

c = r√[2(1 − cosθ)]

This is equivalent to:

c = 2r sin(θ/2)

Chord Example

Suppose:

r = 10

θ = 60°

Then:

c² = 100 + 100 − 200cos60°

= 200 − 100

= 100

Therefore:

c = 10

The Law of Cosines reproduces the standard chord result.

Law of Cosines in Kite Geometry

A Kite Area problem may include two adjacent side lengths and an included angle.

The Law of Cosines can determine the diagonal opposite that angle:

d² = a² + b² − 2ab cosθ

If another diagonal can then be found from the kite’s perpendicular symmetry, area follows from:

A = d₁d₂/2

If area alone is needed and a, b, and θ are known, the shorter formula is often:

A = ab sinθ

Kite Diagonal Example

Suppose:

a = 5

b = 8

θ = 60°

Then:

d² = 25 + 64 − 80(1/2)

= 49

so:

d = 7

The Law of Cosines determines the cross-diagonal separating those two side endpoints.

Line Geometry Application

Suppose two rays begin at the same point and end at points whose coordinates are known.

A Line From Two Points can establish each ray’s direction, while coordinate distances determine the triangle’s three side lengths.

The Law of Cosines can then find the angle where the two rays meet.

This is useful when an angle is required from coordinate data rather than explicit trigonometric ratios.

Navigation and Surveying Interpretation

Suppose two paths of known lengths leave the same location with a known included angle.

The straight-line separation between their endpoints is found by:

c = √(a² + b² − 2ab cosC)

This is a direct SAS application.

The formula therefore appears naturally whenever two displacements and the angle between them are known.

Example With Two Paths

One path has length:

12 km

Another has length:

9 km

The angle between them is:

70°

Endpoint separation:

c = √[12² + 9² − 2(12)(9)cos70°]

= √[225 − 216cos70°]

Using:

cos70° ≈ 0.3420

we obtain:

c ≈ √151.13

Therefore:

c ≈ 12.29 km

Law of Cosines and Interior-Angle Classification

Suppose the three sides are known.

The largest angle lies opposite the longest side.

Calculating only that angle can be enough to classify the triangle.

If the largest angle is:

less than 90° → acute triangle

exactly 90° → right triangle

greater than 90° → obtuse triangle

The remaining Interior Angles must then be smaller.

Isosceles Triangle Example

Suppose:

a = 5

b = 5

c = 6

Find angle C opposite side 6:

cosC = (25 + 25 − 36)/(50)

= 14/50

= 7/25

Therefore:

C = cos⁻¹(7/25)

Approximately:

C ≈ 73.74°

Because:

a = b

the remaining angles are equal.

Each is:

(180° − 73.74°)/2

≈ 53.13°

Equilateral Triangle

For:

a = b = c

use:

c² = c² + c² − 2c²cosC

Divide by:

1 = 2 − 2cosC

Therefore:

2cosC = 1

so:

cosC = 1/2

Thus:

C = 60°

The same argument applies to every angle.

This confirms that an equilateral triangle has three 60° angles.

Triangle Inequality and the Formula

Before solving an SSS triangle, verify:

a + b > c

a + c > b

b + c > a

If the side lengths violate the triangle inequality, no ordinary triangle exists.

The inverse-cosine expression may then produce an invalid input outside:

[−1, 1]

which signals inconsistent side data.

Invalid Side Example

Suppose:

a = 2

b = 3

c = 6

Then:

2 + 3 < 6

so no triangle exists.

If we try:

cosC = (4 + 9 − 36)/(12)

= −23/12

This lies below −1.

A real cosine cannot equal:

−23/12

The invalid inverse-cosine input reflects the failed triangle inequality.

Law of Cosines With Radians

The formula itself does not change when angles are measured in radians:

c² = a² + b² − 2ab cosC

Only the numerical representation of C changes.

For example:

60° = π/3

Therefore:

cos60° = cos(π/3) = 1/2

The Degrees and Radians unit must match the calculator or numerical evaluation.

Radian Example

Suppose:

a = 4

b = 7

C = π/2

Since:

cos(π/2) = 0

we get:

c² = 16 + 49

= 65

Therefore:

c = √65

This is simply the right-triangle case expressed in radians.

Exact Versus Approximate Answers

If the resulting squared side is not a perfect square, the exact radical can be retained.

For example:

c = √79

is exact.

Approximately:

c ≈ 8.89

Likewise, an angle such as:

cos⁻¹(1/7)

is an exact inverse-function expression even though its decimal degree value is approximate.

Avoid rounding intermediate values too early.

Common Law of Cosines Mistakes

A common mistake is pairing the wrong side with the wrong angle.

Remember:

side c ↔ angle C

and the two sides around angle C are a and b.

Another error is forgetting the negative sign:

−2ab cosC

When solving for an angle, divide by:

2ab

before applying inverse cosine.

Do not use SAS logic when the given angle is not between the two known sides.

Check whether the problem is better suited to the Law of Sines.

Ensure the calculator is in the correct degree or radian mode.

For SSS data, verify the triangle inequality.

Finally, when calculating all three angles, use the 180° angle sum for the final angle rather than introducing unnecessary additional rounding.

Frequently Asked Questions

What is the Law of Cosines?

For side c opposite angle C:

c² = a² + b² − 2ab cosC

When should I use the Law of Cosines?

It is especially useful for:

SAS

and:

SSS

triangle problems.

How do you find a missing side?

c = √(a² + b² − 2ab cosC)

How do you find an angle?

C = cos⁻¹[(a² + b² − c²)/(2ab)]

Is the Law of Cosines the same as the Pythagorean theorem?

The Pythagorean theorem is the special case where:

C = 90°

because:

cos90° = 0

Can the Law of Cosines solve obtuse triangles?

Yes.

Can it solve acute triangles?

Yes.

Does it work for right triangles?

Yes.

Which side corresponds to angle C?

Side c, the side opposite C.

Does the Law of Cosines require a right triangle?

No.

What is the difference between the Law of Cosines and Law of Sines?

The Law of Cosines is usually most direct for SAS and SSS. The Law of Sines is usually most direct when an opposite side-angle pair is known.

Can the Law of Cosines classify a triangle?

Yes. For longest side c, compare:

with:

a² + b²

to distinguish acute, right, and obtuse triangles.

A chord and two radii form a triangle, giving:

c² = 2r²(1 − cosθ)

How can I check a Law of Cosines answer?

Verify side-angle correspondence, check the triangle inequality, confirm the side lies between |a − b| and a + b, and use the angle sum or another triangle relationship to verify the result when possible.

Mehran Khan

Mehran Khan is the primary author at The Logic Library and CEO & Founder of One Digit Media. With 10+ years of experience in software engineering, SEO, and digital publishing, he uses a research-led approach to Logics, Maths, Tech, Formulas, Science, and AI.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button