Use the law of cosines when a triangle is not right and you know either two sides with the included angle or all three sides. For sides , , opposite angles , , , the standard form is
Here, side is opposite angle , and is the angle between sides and . The same pattern works for the other sides:
If , then , so the formula becomes . That is why the law of cosines is a generalization of the Pythagorean theorem.
When to use the law of cosines
The most common setup is SAS: two sides and the included angle. The included angle means the angle formed by those two known sides.
It also works for SSS: all three sides are known, and you want an angle. In that case, rearrange the formula before using inverse cosine.
If you already know a side and its opposite angle, the law of sines is often the better first tool.
What the formula means
If two sides stay fixed, the third side depends on the angle between them.
When the included angle gets larger, the opposite side gets longer. When the angle gets smaller, the opposite side gets shorter. The term adjusts the simple sum to account for that angle.
That correction term is the part people should remember. Without it, you would be treating every triangle like a right triangle.
Worked example: find a side
Suppose a triangle has sides and , and the included angle is . Find side .
Because is opposite the known angle , use
Substitute the values:
Since ,
So
That answer makes sense: the third side is longer than but shorter than , and the angle is moderate rather than extremely large.
How to find an angle from three sides
If all three sides are known, solve for the cosine first:
Then compute
This only makes sense when , , and form a valid triangle. If the value inside is outside the interval , there is an earlier algebra or data error.
A short proof idea
One clean proof comes from coordinates.
Place one side on the -axis. Let one vertex be at and another at . Put the third vertex at because that point is distance from the origin and makes angle with the -axis.
Now use the distance formula between and :
Expand:
Then use
to combine the last two terms:
That is the law of cosines.
Common mistakes
Matching the wrong side and angle
The angle in the formula must be opposite the side on the left side of the equation. If you use angle , then the left side must be .
Using the formula as if every triangle were right
If the angle is not , you cannot drop the term.
Forgetting calculator mode
If the problem gives degrees, your calculator must be in degree mode. If it gives radians, use radian mode.
Solving for an angle without isolating cosine carefully
When all three sides are known, rearrange first, then use inverse cosine. A small algebra mistake there can push the final angle off by a lot.
Where the law of cosines is used
The law of cosines is common in geometry, trigonometry, surveying, navigation, and any problem where you need distances in a non-right triangle.
In school math, the two main uses are:
- finding a missing side from two sides and the included angle
- finding a missing angle from all three sides
If you already have a right triangle, the Pythagorean theorem is usually the simpler version. If you know angles with a side pair instead, the law of sines may be a better fit.
Try your own version
Take , , and , then find . After that, change to and compare the result. Watching the opposite side grow is one of the fastest ways to make the formula feel intuitive.
If you want step-by-step feedback with your own numbers, explore a similar triangle in GPAI Solver.
Need help with a problem?
Upload your question and get a verified, step-by-step solution in seconds.
Open GPAI Solver →