Law of Cosines Calculator
Solve a triangle when you know two sides and the included angle (SAS), or all three sides (SSS). Find the remaining measurements with the law of cosines.
Your triangle measurements
Enter the known sides and angle, or choose an example, then select Calculate.
Show calculation
How to use this calculator
- Choose SAS if you know two sides and the angle between them, or SSS if you know all three sides.
- Enter the known measurements and select Calculate.
- Review the missing side lengths, angles, area, perimeter and calculation steps.
Law of cosines formula
For sides a, b and c opposite angles A, B and C, a² = b² + c² − 2bc cos(A). The same relationship applies cyclically to the other sides and angles. When all three sides are known, cos(A) = (b² + c² − a²)/(2bc).
When to use the law of cosines
Use this formula for SAS or SSS information. Unlike the law of sines, the SAS case has no ambiguous second triangle. When A = 90°, the cosine term is zero and the expression reduces to the Pythagorean theorem.
Worked example — SAS
This example uses sample values, not your current inputs.
Suppose b = 5, c = 7 and A = 60°. Then a² = 25 + 49 − 70 cos(60°) = 39, so a = √39 ≈ 6.244998. The other angles are approximately B = 43.897886° and C = 76.102114°.
Frequently asked questions
When should I use the law of cosines?
Use it to solve a triangle from two sides and their included angle (SAS) or from all three side lengths (SSS).
What is the difference between the law of sines and the law of cosines?
The law of sines compares each side with the sine of its opposite angle. The law of cosines connects three sides with the cosine of an included angle, making it useful for SAS and SSS inputs.
Can I use it for a right triangle?
Yes. With a 90° included angle, cos(90°) = 0, so the side-length formula becomes the Pythagorean theorem.
Why are my three sides rejected?
Three lengths form a nondegenerate triangle only if each side is shorter than the sum of the other two sides. Equality describes a flat, degenerate configuration.
Do I need to enter angles in radians?
No. Enter angles in degrees. The calculator converts them internally when evaluating trigonometric functions.
Scientific foundations and academic references
The mathematical foundations, computational method and limitations of this tool.
Foundational research
Euclid, Elements, Book II, Propositions 12–13
Euclid's Elements, Book II, Propositions 12 and 13 give geometric results for obtuse and acute triangles that correspond to the later algebraic law of cosines. They extend the geometry behind the Pythagorean theorem.
Read source (opens in a new tab)Euclid, Elements, Book II, Propositions 12–13
Read source (opens in a new tab)Theoretical development · 1967
H. S. M. Coxeter & S. L. Greitzer, Geometry Revisited (1967), Mathematical Association of America
Coxeter and Greitzer's Geometry Revisited (1967) presents the modern geometric framework for relating triangle sides, angles and circle constructions.
Read source (opens in a new tab)Authoritative technical references
Eric W. Weisstein, Law of Cosines, Wolfram MathWorld
Eric W. Weisstein, Law of Cosines, Wolfram MathWorld
Wolfram MathWorld lists the three cyclic cosine identities and their inverse forms for recovering angles from side lengths.
Read source (opens in a new tab)Computational method and verification
Numerical computation
SAS calculations evaluate the included-angle cosine; SSS calculations use inverse trigonometric relationships after strict triangle-inequality validation. Angles are reported in degrees. All numerical evaluations use IEEE 754 double-precision arithmetic with rounding applied to displayed results.
- b = 5, c = 7, A = 60°
- a = √39 ≈ 6.244998
- a = 3, b = 4, c = 5
- C = 90°, area = 6
- a = 1, b = 2, c = 3
- Rejected: degenerate triangle
Scope and limitations
For SAS inputs, the unknown side is computed from a² = b² + c² − 2bc cos A. For SSS inputs, inverse cosine recovers the angles after the strict triangle inequality is checked. All computations refer to plane Euclidean triangles, with degrees as the user-facing angle unit. Final displayed decimals may be rounded; intermediate calculations retain unrounded numeric values.
Read full methodologyCite this tool
Use the following citation when referencing this calculator.
APA 7th edition
Statistics Calculator Lab. (2026). Law of Cosines Calculator [Online calculator]. https://statscalculator.org/law-of-cosines-calculator/
Show BibTeX
@misc{statscalculator_law_of_cosines_2026,
author = {{Statistics Calculator Lab}},
title = {Law of Cosines Calculator},
year = {2026},
howpublished = {Online calculator},
url = {https://statscalculator.org/law-of-cosines-calculator/}
}