Law of cosines formula
The law of cosines finds a missing side or angle in any triangle, not just right triangles. It generalizes the Pythagorean theorem by adding a term that corrects for the angle between two sides.
What each symbol means
| Symbol | Meaning | Units |
|---|---|---|
| a, b | Two known sides | any length unit |
| c | Side opposite angle C | same unit |
| C | Angle between sides a and b | degrees |
Rearranged forms
Worked example
Two sides measure 5 and 7 with a 60° angle between them. Find the third side.
- Start from c² = a² + b² − 2ab·cos C.
- Substitute a = 5, b = 7, C = 60° (cos 60° = 0.5).
- Compute: c² = 25 + 49 − 2·5·7·0.5.
- Simplify: c² = 74 − 35 = 39.
- Square root: c = √39.
Sides share one length unit; the angle is the one between the two known sides. When C = 90°, cos C = 0 and the formula collapses to the Pythagorean theorem. Use the law of sines instead when you already have an angle and its opposite side.
Have two sides and the included angle?
Enter your sides and angle and the Law of Cosines Calculator solves for the remaining side or angle.
How the law of cosines works
In a right triangle the Pythagorean theorem holds exactly. When the angle between two sides is not 90 degrees, the law of cosines subtracts 2ab times the cosine of that angle to correct for it. A wider angle stretches the opposite side; a narrower one shortens it.
Where it is used
It solves triangles in surveying, navigation, engineering, and physics whenever you know two sides and the included angle, or all three sides. It is the go-to tool for non-right triangles alongside the law of sines.
FAQ
When do I use the law of cosines?
When you know two sides and the angle between them to find the third side, or all three sides to find an angle. It works for any triangle.
How is it related to the Pythagorean theorem?
It is a generalization. When the included angle is 90°, its cosine is zero and the formula reduces to c² = a² + b².
Can it find an angle?
Yes. Rearranged, C = cos⁻¹[(a² + b² − c²) / (2ab)], which gives the angle from all three sides.
