Try it with your numbers
Show every step
Right-triangle ratios from SOH CAH TOA stop working the moment a triangle has no right angle. The law of cosines is the Pythagorean theorem with one correction term attached, and that term is the whole story.
What is the law of cosines and when do you use it?
Label the triangle so that side faces angle , side faces angle and side faces angle . The law then comes in three matching versions, one per side:
The pattern never changes: the side on the left and the angle inside the cosine are opposite each other, and the other two sides appear squared and then multiplied together. Students who mix up which angle goes where almost always have a sketch with unlabeled or mislabeled opposite pairs, so draw the triangle first.
The law is for two situations. If you know two sides and the included angle (the angle between them, called SAS), it gives the third side. If you know all three sides (SSS), solve the formula for the cosine and it gives any angle:
If you instead know two angles and a side, the law of sines is the shorter route.
Quick check
Answer:
Where does the law of cosines come from?
The whole proof is the distance formula plus one identity. Put angle at the origin, lay side along the positive -axis so that , and then vertex sits at . Side is the distance between and :
Expand the squares and collect terms:
The last step uses , one of the Pythagorean identities, to merge the two terms.
The quantity is how far vertex sits along side (its shadow). The term adjusts the Pythagorean sum for that lean: positive cosine shrinks , negative cosine stretches it.
This also explains why no triangle-specific trick is needed. Any triangle can be rotated so one angle sits at the origin, so the formula holds for every triangle, acute or obtuse.
How do you find a missing side with the law of cosines?
Take , and the included angle . Side is opposite , so use the version with :
Evaluate the product first: . Then , and finally .
Three traps cost most of the points here. First, subtracting before multiplying: is a different, wrong expression, because must be computed as a single product. Second, stopping at and forgetting the square root. Third, a calculator in the wrong mode: with the angle in degrees, the calculator must be in degree mode, and if the problem gives radians, convert with degrees to radians or radians to degrees first.
A fast reasonableness check: with and , the third side must land between and , and a angle is narrow, so a result near the low end like makes sense.
How do you find an angle with the law of cosines?
Take a triangle with sides , and . Start with the largest angle, the one opposite , and call it :
Then . Keep the fraction exact until the last button press: rounding to first would move the answer to about .
Finding the largest angle first is a deliberate choice. Once it is known, the other two angles must be acute, so there is no sign worry for them. Using the same formula for the angle opposite gives , so . The third angle is , and you can confirm it directly with , which gives as well. The last step uses inverse trigonometric functions, and unlike the inverse sine, the inverse cosine never leaves two candidate answers.
Try this: Find the angle opposite the side of length in a -- triangle using the formula (you should get ). Then change the to and predict whether the angle rises above or falls below before you calculate.
How does the law of cosines work with obtuse angles?
Suppose , and . The cosine of is negative: its reference angle is , and in the second quadrant cosine flips sign, so (this value comes straight off the unit circle). Then:
So . Subtracting a negative number is an addition, which is where hand calculations go wrong: students write and get , which would make , shorter than a side next to it. An obtuse angle must push its opposite side outward.
You can read the angle type from the sides alone, without a calculator. Compare with . If , then and the angle is obtuse; if they are equal, it is a right angle; if is smaller, the angle is acute. In the example above, confirms the obtuse angle before any trigonometry is done.
Quick check
Answer: obtuse
Which special cases of the law of cosines are worth knowing?
At the cosine is , so the formula collapses into . That is the Pythagorean theorem, and it is the reason the correction term is the only new idea. Two other angles give clean shortcuts because their cosines are :
With sides and at , that is in one line, with no calculator.
For a real triangle, , so always lies strictly between and . Equivalently, .
The edges of that range are the degenerate triangles. At the sides lie flat in a line and , so . At the sides overlap and . Any answer outside that interval signals an arithmetic slip.
Law of cosines or law of sines: which one do you use?

The choice depends on which three pieces of the triangle are given, not on personal preference.
| Given | Best tool |
|---|---|
| Two sides and the included angle (SAS) | Law of cosines |
| Three sides (SSS) | Law of cosines |
| Two angles and any side (ASA or AAS) | Law of sines |
| Two sides and a non-included angle (SSA) | Law of sines, or cosines with a quadratic |
The SSA case deserves care. With , and , the law of cosines on side gives , which simplifies to . The discriminant is , so , about or . Both are positive, so two different triangles fit the data. Solving the quadratic by the quadratic formula shows the ambiguity openly instead of hiding it inside an inverse sine.
A strong combined strategy for SSS problems: use the law of cosines once for the largest angle, then switch to the law of sines for the rest. Since the remaining angles are guaranteed acute, the sine method cannot mislead you.
How do you check a law of cosines answer?
Four quick tests catch nearly every error:
- The third side must satisfy .
- The side opposite the larger angle must be the longer side.
- Compare with : your angle should be acute if is smaller, obtuse if larger.
- After finding all three angles, the sum must be (rounding may cause a gap).
The third test is the sharpest, because it exposes both mode errors and sign errors. If a angle produced a larger than , the cosine came out negative, and the calculator is almost certainly set to radians.
You can also substitute your answer back in. For the -- example, gives , which matches . That round trip takes ten seconds and confirms the arithmetic.
Quick check
Answer: c must be below about 11.4
Where is the law of cosines used in real life?
Any time two distances and the angle between them are known, the distance between the endpoints follows. Two boats leave the same dock: one travels km on a bearing of and the other km on a bearing of . The angle between the paths is , so:
Then km. The same triangle has an area of km², which follows from the area of a triangle using sine.
Surveyors use the formula to measure across lakes and fields they cannot cross, often combined with angles of elevation and depression to handle slopes. In physics, the resultant of two forces or velocities is a law of cosines problem: the magnitude of depends on the angle between the vectors through . Because the triangle’s interior angle is , the sign flips relative to the formula above.
Practice problems
0 of 5 solved
- In a triangle, , and the angle between them is . Find side .
Answer:
Write . Since , this is . So . - A triangle has sides , and . Find the angle opposite the side of length .
Answer:
Use . Then . - In a triangle, , and the angle between them is . Find side .
Answer:
Since , . That is . So . - A triangle has sides , and . Find its largest angle.
Answer:
The largest angle faces the side of length . . So , which is acute. - A parallelogram has sides and and a long diagonal of . Find the length of the short diagonal.
Answer:
In the triangle with sides , , : , so . The neighboring angle of the parallelogram is . Short diagonal: , so .
Common questions
What is the formula for the law of cosines?
For a triangle with sides , , and opposite angles , , , the law is . The same pattern works for any side: square the side you want, and use the angle opposite it.
When do you use the law of cosines instead of the law of sines?
Use the law of cosines when you know two sides and the angle between them (SAS) or all three sides (SSS). Use the law of sines when you know a side and its opposite angle plus one more piece of information.
Can the law of cosines be used on a right triangle?
Yes. At the term is zero, and the formula becomes the Pythagorean theorem . That is why the law of cosines is called a generalization of Pythagoras.
Why is the law of cosines negative for obtuse angles?
The cosine of an angle between and is negative, so subtracting actually adds to . The side opposite an obtuse angle is therefore longer than the hypotenuse of a right triangle with the same two legs.
Does the law of cosines have an ambiguous case?
Not when you solve for an angle, because the inverse cosine returns a single angle between and . Ambiguity appears only in the side-side-angle setup, where solving for the third side gives a quadratic that can have two positive roots.
How do you find an angle with the law of cosines?
Rearrange the formula to , substitute all three sides, and apply the inverse cosine. Keep the fraction exact until the last step to avoid rounding errors.