Law of Cosines Calculator
Find missing sides or angles of any triangle using the Law of Cosines. Supports SSS (all sides known) and SAS (two sides + included angle) modes.
Did this tool work for you?
How to use this calculator
The Law of Cosines generalizes the Pythagorean theorem to any triangle. Given three sides (SSS) it finds any angle; given two sides and the included angle (SAS) it finds the third side.
- 1
Choose your mode: SAS (two sides and the angle between them) or SSS (all three sides).
- 2
Enter side a, side b, and either angle C (SAS) or side c (SSS).
- 3
The calculator returns the missing side or angles, plus the area and perimeter.
- 4
Angles are in degrees; sides share the same unit.
Frequently asked questions
When should I use the Law of Cosines vs. the Law of Sines?
Use the Law of Cosines when you have SSS (all three sides) or SAS (two sides and the included angle). Use the Law of Sines when you have AAS or ASA configurations. The Law of Cosines is also preferred for SSA cases to avoid the "ambiguous case" ambiguity.
Does the Law of Cosines work for right triangles?
Yes. When angle C = 90°, cos(90°) = 0, so the formula reduces to c² = a² + b² — exactly the Pythagorean theorem. The Law of Cosines is a generalization valid for all triangles.
What is the triangle inequality?
For any valid triangle, each side must be less than the sum of the other two sides: a < b + c, b < a + c, c < a + b. If your three sides violate this rule, no real triangle exists and the calculator will report an error.
How is area calculated from three sides?
When all three sides are known, Heron's formula gives the area: s = (a+b+c)/2, then Area = √[s(s−a)(s−b)(s−c)]. This calculator uses that formula to display area in SSS mode.
Law of Cosines — solve any triangle from sides and angles
The formula and its derivation
The Law of Cosines states c² = a² + b² − 2ab·cos(C), where C is the angle opposite side c. It follows from dropping an altitude in a general triangle and applying the Pythagorean theorem to the two resulting right triangles. Because cosine can be negative (for obtuse angles), the formula naturally handles all triangle types — acute, right, and obtuse — without special cases.
SSS vs SAS: choosing the right mode
In SSS mode all three sides are known; the formula is rearranged as cos(C) = (a² + b² − c²) / (2ab) to recover each angle in turn. In SAS mode the included angle C and its two flanking sides a, b are known; the formula solves directly for c. Either way the remaining angles are then found using the same formula (or, once two angles are known, by subtraction from 180°).
Practical uses in navigation and surveying
Surveyors use the Law of Cosines constantly: given two measured distances from a baseline and the angle at the surveying instrument, they calculate the distance across a river, ravine, or building without crossing it. GPS systems and cellular towers use triangulation based on the same principle. In game development and computer graphics, the law determines the angle between two 3D vectors — a step in lighting and collision calculations.
Learn more from an authoritative source:
WikipediaScientific Calculator
Evaluate mathematical expressions including trigonometry, logarithms, exponents, and more.
Percentage Calculator
Quickly calculate percentages, percentage change, and percentage of a total.
Fraction Calculator
Add, subtract, multiply, or divide two fractions and get the simplified result instantly.
Ratio Calculator
Simplify ratios, find missing values, and scale ratios up or down.
Results are estimates for informational purposes only and do not constitute professional financial, medical, legal, or technical advice. Read full disclaimer →