Skip to content

Law of Cosines

Generalizes the Pythagorean theorem to all triangles.

Variables

C
Angle between sides a and b

Explanation

When , and it reduces to . Use it for SSS and SAS triangles.

Example

: , .

How to use it

  • Two sides and the included angle (SAS): find the third side with .
  • Three sides (SSS): rearrange to find an angle, .

Another worked example (SSS)

A triangle has sides , and . Find the largest angle, which is because it's opposite the longest side.

So . A negative cosine always means an obtuse angle.

Real-world example

Two hikers leave camp along paths apart. One walks 4 km and the other 6 km. How far apart are they?

Why it works

Drop a perpendicular from one vertex to the opposite side, splitting the triangle into two right triangles. Applying the Pythagorean theorem to each and eliminating the shared height leaves the correction. When , and you get back .

Law of cosines or law of sines?

Use cosines for SAS and SSS. Use sines when you know a side and its opposite angle. After finding one angle with cosines, switching to sines is quicker, but the law of cosines never has an ambiguous case, so it's safer for the largest angle.

Common mistakes

  • Using an angle that isn't between the two known sides.
  • Calculating . Only the term is multiplied by .
  • Calculator in radians mode.

Where it's used

  • Navigation: distance between two ships that sailed from the same port on different headings.
  • Sport: the distance from home plate to a fielder, or a golf ball's offline distance.
  • Engineering: finding lengths in linkages, robot arms and frames.
  • Physics: adding two forces or velocities at an angle to find the resultant's size.

Key takeaways

  • Use it for SAS and SSS triangles.
  • Only the term is multiplied by .
  • A negative cosine means an obtuse angle.

Try it: Triangle Calculator

Solve any triangle from SSS, SAS or ASA: all sides, angles, area, perimeter and type using the laws of sines and cosines.

Open calculator

Practice problems

Try each one first, then open the answer to check your work.

  1. 1., , . Find .

    Show answer

    10.

  2. 2., , . Find .

    Show answer

    , .

  3. 3.Sides 5, 6, 7. Find the largest angle.

    Show answer

    , .

  4. 4.Sides 3, 3, 3. Find any angle.

    Show answer

    , so .

  5. 5., , . Find .

    Show answer

    10. The triangle is equilateral.

Key terms

SAS
Two sides and the included angle are known.
SSS
All three sides are known.
Included angle
The angle between two known sides.
Obtuse angle
An angle greater than .
Inverse cosine
, which finds an angle from its cosine.

Frequently asked questions

When do I use the law of cosines?

When you know two sides and the angle between them (SAS) or all three sides (SSS). Those are the cases the law of sines can't start.

What does a negative cosine tell me?

That the angle is obtuse, between and .

Why is it called a generalised Pythagorean theorem?

The extra term corrects for the angle not being . When it is , the term vanishes.

Which angle should I find first in SSS?

The largest, opposite the longest side. Then use the law of sines for the rest, knowing they must both be acute.

How do I add two forces at an angle?

If forces and act with angle between them, the resultant has size . The plus sign appears because the triangle's angle is .

Can it check whether three lengths form a triangle?

Yes. If the cosine you compute is outside to , no triangle exists.

Can I find all angles with the law of cosines?

Yes. Rearrange for each angle in turn. As a check, they should add to .

What is the law of cosines when $C = 180°$?

, so and . The triangle has flattened into a straight line.

Is there a vector version?

Yes. , since the dot product is .

Related formulas

More trigonometry formulas