How the Law of Cosines works
The Law of Cosines generalizes the Pythagorean theorem to work with any triangle, not just right triangles. For a triangle with sides a, b, and c, where angle C is the angle opposite side c (and included between sides a and b), the Law of Cosines states c² = a² + b² − 2ab·cos(C). This calculator uses that relationship to find a missing side from two sides and their included angle (SAS), then derives the remaining two angles and the triangle's area from the result.
Formula and derivation
The formula comes from dropping a perpendicular from one vertex to the opposite side and applying the Pythagorean theorem to the two right triangles that result, then substituting cos(C) for the ratio that appears from the adjacent leg. When C = 90°, cos(C) = 0 and the formula collapses to the familiar c² = a² + b², confirming the Law of Cosines is a true generalization rather than a separate rule.
Solving a triangle: SAS and SSS
Given two sides and the included angle (SAS), enter a, b, and angle C to solve for side c directly. Once c is known, the same formula can be rearranged to solve for either remaining angle: cos(A) = (b² + c² − a²) / (2bc) and cos(B) = (a² + c² − b²) / (2ac); taking the inverse cosine of each gives angle A and angle B. The same rearranged formula, cos(C) = (a² + b² − c²) / (2ab), is what you would use if instead you started with all three sides (SSS) and needed to find an angle.
Common mistakes
- Using the wrong angle: angle C must be the angle between sides a and b (the included angle) — using a non-included angle gives an incorrect side c.
- Mixing degrees and radians: make sure the angle unit you select matches how you measured the angle, since cos(60) and cos(60°) are very different numbers.
- Invalid triangles: the included angle must be strictly between 0° and 180°, and all three sides must be positive, or no triangle exists.
Real-world applications
- Surveying and navigation use the Law of Cosines to find distances between points when direct measurement is impossible but two legs and a turning angle are known.
- Engineering and construction use it to check truss and framing geometry where triangles are not right triangles.
- Physics uses the same formula (as the law of cosines for vectors) to find the magnitude of a resultant vector from two vectors and the angle between them.
- Navigation and GPS triangulation use it alongside the Law of Sines to fully solve triangles formed by known landmarks or waypoints.