Geometry & Trigonometry

Law of Cosines How to Find Missing Sides and Angles in Any Triangle

Every middle school student knows the world famous Pythagorean theorem: a squared plus b squared equals c squared. It is the most beloved formula in geometry, but it has one giant limitation: it only works if your triangle has an exact ninety-degree right angle! What happens if you have an obtuse angle wider than 90 degrees, or a sharp acute angle?

Mathematicians created a generalized version of the Pythagorean theorem that works for absolutely any triangle in the universe. That powerful formula is called the Law of Cosines. By testing triangle measurements on Calcsolver, students, sailors, and GPS engineers can calculate unknown side lengths and interior angles when the Law of Sines cannot even get started.

Understanding the Law of Cosines unlocks long-distance flight navigation, structural bridge trusses, and advanced trigonometry.

What is the Law of Cosines and How Does It Generalize Pythagoras

The Law of Cosines (also known as the Cosine Rule) relates the lengths of all three sides of a triangle to the cosine of one of its interior angles. It is essentially the Pythagorean theorem with a built-in correction factor that accounts for non-right angles.

For a triangle with side lengths a, b, and c, and angle C opposite to side c:

c^2 = a^2 + b^2 - 2ab cos(C)

Notice what happens if Angle C is exactly 90 degrees: the cosine of 90 degrees is zero (cos(90) = 0). The entire correction term -2ab cos(C) completely vanishes, leaving: c^2 = a^2 + b^2. The Pythagorean theorem is simply a special case of the Law of Cosines!

Also read: Law of Sines How to Solve Non Right Triangles with Solved Examples

You may also like: Complementary and Supplementary Angles Rules and Solved Word Problems

The Three Forms of the Law of Cosines

Depending on which unknown side you are solving for, the formula can be written with any side as the subject:

  • Solving for side c: c^2 = a^2 + b^2 - 2ab cos(C)
  • Solving for side b: b^2 = a^2 + c^2 - 2ac cos(B)
  • Solving for side a: a^2 = b^2 + c^2 - 2bc cos(A)

To solve for an unknown interior angle when all three sides (SSS) are known, rearrange the formula algebraically:

cos(C) = (a^2 + b^2 - c^2) / (2ab)

When Must You Use the Law of Cosines

The Law of Cosines is required in two specific geometric scenarios where the Law of Sines fails because zero matching angle-side pairs exist:

  • Scenario 1 (SAS - Side-Angle-Side): You know two side lengths and the included angle sandwiched directly between them.
  • Scenario 2 (SSS - Side-Side-Side): You know the lengths of all three sides, but zero interior angles are given.

Step by Step Worked Marine Navigation Example (SAS Case)

Let us solve a realistic coastal ship navigation problem. A cargo ship departs from harbor Port A and sails due east for 10 nautical miles (side b = 10). A second fishing vessel leaves the same harbor and sails northeast along a heading that forms a 60-degree angle with the cargo ship for 15 nautical miles (side a = 15). How far apart are the two ships?

Step one: Identify the known SAS parameters: a = 15, b = 10, and included angle C = 60 degrees. We need to find distance c.

Step two: Write out the Law of Cosines: c^2 = a^2 + b^2 - 2ab cos(C).

Step three: Square the known sides: 15^2 = 225, and 10^2 = 100. Sum = 225 + 100 = 325.

Step four: Compute the correction term: 2 x 15 x 10 x cos(60). Look up cos(60 degrees), which is exactly 0.5. 2 x 15 x 10 x 0.5 = 150.

Step five: Subtract the correction term: c^2 = 325 - 150 = 175.

Step six: Take the square root: c = sqrt(175) equals approximately 13.23 nautical miles. The two ships are 13.23 nautical miles apart.

Problem Scenario Given Input Values Formula Configuration Calculated Unknown Result
SAS: Acute Included Angle a = 8, b = 11, Angle C = 45 deg c^2 = 8^2 + 11^2 - 2(8)(11)cos(45) c = 7.78 units
SAS: Right Angle Benchmark a = 3, b = 4, Angle C = 90 deg c^2 = 3^2 + 4^2 - 2(3)(4)cos(90) c = 5.00 units (Pythagoras)
SAS: Obtuse Included Angle a = 5, b = 7, Angle C = 120 deg c^2 = 5^2 + 7^2 - 2(5)(7)cos(120) c = 10.44 units (cos(120)=-0.5)
SSS: Find Largest Angle a = 6, b = 8, c = 12 cos(C) = (6^2 + 8^2 - 12^2) / [2(6)(8)] Angle C = 117.28 degrees (Obtuse)

How the Law of Cosines Handles Obtuse Angles Naturally

When an angle is obtuse (greater than 90 degrees), its cosine is a negative number: for example, cos(120 degrees) = -0.5. In the equation, subtracting a negative term turns into addition: - 2ab(-0.5) = + ab.

This addition naturally forces c^2 to be larger than a^2 + b^2, perfectly matching the geometric reality that the side opposite an obtuse angle must be the longest side of the triangle.

Frequently Asked Questions About the Law of Cosines

Which Angle Should You Solve for First in an SSS Triangle

Always solve for the largest angle first (the angle opposite the longest side). Because the inverse cosine function (arccos) cleanly returns angles from 0 to 180 degrees without ambiguity, you immediately discover whether the triangle is obtuse.

Can the Law of Cosines Result in Negative Distance

No. When you take the square root of c^2, you always take the positive principal root because physical geometric length is strictly positive.

Why is the Law of Cosines Preferred Over the Ambiguous SSA Case

Unlike the Law of Sines which can produce two ambiguous angles, the inverse cosine function is strictly one-to-one between 0 and 180 degrees, producing a single guaranteed unique angle answer every time.

Calculate geometric shapes and angles with live steps:

Solve equations with instant step-by-step verified logic on CalcSolver.live.

Open Interactive Geometry Solver →
← Back to All Math & Science Articles