Last verified · v1.0
Calculator · math
Law Of Cosines Triangle Calculator
Solve any triangle using the law of cosines. Enter two sides and an included angle (SAS) to find the third side, or all three sides (SSS) to find a missing angle.
Inputs
Computed Value (side length or angle in degrees)
—
Explain my result
Get a plain-English breakdown of your result with practical next steps.
The formula
How the
result is
computed.
Understanding the Law of Cosines
The law of cosines is a foundational trigonometric relationship that generalizes the Pythagorean theorem to any triangle — scalene, isosceles, acute, or obtuse. This cosine triangle calculator solves two classic triangle problems: finding a missing side when two sides and the included angle are known (SAS mode), and finding a missing angle when all three sides are known (SSS mode).
The Core Formula
The law of cosines takes two equivalent forms depending on the unknown quantity:
- Solving for side c (SAS): c² = a² + b² − 2ab · cos(C)
- Solving for angle C (SSS): C = arccos((a² + b² − c²) / (2ab))
In both expressions, a, b, and c represent the three side lengths of the triangle, and C is the interior angle opposite side c. According to Khan Academy's law of cosines tutorial and the Texas A&M University Mathematics curriculum (Section 8.5), this formula is the authoritative standard for non-right triangle computation in trigonometry.
Variable Definitions
- a — Length of the first side. Must be a strictly positive real number.
- b — Length of the second side. Must be a strictly positive real number.
- c — Length of the third side, opposite angle C. Required in SSS (angle-solving) mode only. Must satisfy the triangle inequality: |a − b| < c < a + b.
- Angle C — The interior angle between sides a and b, measured in degrees. Required in SAS (side-solving) mode only. Must fall strictly between 0° and 180°.
Mathematical Derivation
The law of cosines derives from the Pythagorean theorem applied to a triangle with an altitude dropped from vertex C perpendicular to side c. This altitude h creates two right triangles. Applying the Pythagorean theorem to each and combining results using the identity sin²(x) + cos²(x) = 1 yields c² = a² + b² − 2ab·cos(C) directly. When C = 90°, cos(90°) = 0, and the formula reduces to c² = a² + b² — the Pythagorean theorem exactly — confirming it as a special case of the more general law.
Worked Examples
Example 1: SAS — Finding a Missing Side
A land surveyor measures two boundary fences from a corner post: a = 120 m, b = 95 m, with an included angle of C = 47°. Applying the SAS formula: c² = 120² + 95² − 2(120)(95) · cos(47°) = 14400 + 9025 − 22800 · 0.6820 ≈ 23425 − 15550 = 7875. Therefore c ≈ 88.7 m.
Example 2: SSS — Finding a Missing Angle
A triangular plot of land has measured sides of a = 200 ft, b = 175 ft, and c = 150 ft. Applying the SSS formula: C = arccos((200² + 175² − 150²) / (2 · 200 · 175)) = arccos((40000 + 30625 − 22500) / 70000) = arccos(48125 / 70000) = arccos(0.6875) ≈ 46.6°.
Law of Cosines vs. Law of Sines: Choosing the Right Tool
The law of cosines applies specifically in two scenarios: (1) SAS — two sides and their included angle are known, and (2) SSS — all three sides are known. The law of sines is more efficient for AAS and ASA configurations. For SSS problems, the law of cosines delivers a direct, unambiguous solution and avoids the ambiguous-case complications that can arise when applying the law of sines to side-side-angle configurations.
Real-World Applications
- Surveying: Calculating distances across terrain where direct measurement is impractical.
- Navigation: Determining a vessel's position from two reference bearings and the angle between them.
- Structural engineering: Verifying diagonal bracing lengths in non-rectangular frames and trusses.
- Physics: Computing resultant vector magnitudes when two forces act at an oblique angle.
- Computer graphics: Calculating polygon edge angles for 3D mesh rendering pipelines.
Input Constraints and Validation
All side lengths must be strictly positive. In SSS mode, the three sides must satisfy the triangle inequality; if the quantity (a² + b² − c²) / (2ab) falls outside the interval [−1, 1], no valid triangle exists with those dimensions. In SAS mode, angle C must be strictly between 0° and 180°; at either boundary the triangle degenerates to a line segment with zero area and no computable geometry.
Reference