Law of Cosines Calculator — Side & Angle Solver
Solve triangles using the law of cosines. Find missing sides (SSS) or angles (SAS) with step-by-step work.
Law of Cosines
Results update instantly as you type
Enter Values
Embed Code
Copy and paste this HTML snippet into any web page to embed this calculator directly.
<iframe src="http://127.0.0.1:54963/embed/math/law-of-cosines?ref=embed" title="Law of Cosines Calculator — Side & Angle Solver" width="100%" style="max-width:600px; border:none; height:500px;" loading="lazy"></iframe>
Direct Link
Share this link to let others open the calculator in their browser.
The Formula
The law of cosines generalizes the Pythagorean theorem to any triangle. It relates the lengths of the sides of a triangle to the cosine of one of its angles. For a triangle with sides a, b, c and angle C opposite side c, the formula states that c² equals the sum of the squares of the other two sides minus twice their product times the cosine of the included angle. When C = 90°, cos(90°) = 0 and the formula reduces to c² = a² + b², which is the familiar Pythagorean theorem for right triangles.
Variable Definitions
Side lengths
The lengths of the three sides of the triangle, with c being the side opposite angle C.
Angle C
The angle opposite side c, measured in degrees. In SAS mode, this is the angle between sides a and b.
Cosine of angle C
The trigonometric cosine function evaluated at angle C, ranging from -1 to 1.
How to Use This Calculator
- 1
Select the mode: "Side (SSS)" when you know all three side lengths, or "Angle (SAS)" when you know two sides and the included angle.
- 2
In SSS mode, enter the lengths of all three sides (a, b, c). The calculator finds each angle using the law of cosines step by step.
- 3
In SAS mode, enter two side lengths (a, b) and the included angle (C) between them. The calculator finds the third side and the remaining angles.
- 4
Review the work steps section to see each calculation step, including cosine evaluations and inverse cosine operations.
- 5
Ensure your inputs satisfy the triangle inequality (SSS) or that the given angle is less than 180 degrees (SAS) for a valid triangle.
Quick Reference
| From | To |
|---|---|
| c² formula | c² = a² + b² − 2ab·cos(C) |
| cos(C) formula | cos(C) = (a² + b² − c²)/(2ab) |
| Right triangle | If C = 90°, cos(C) = 0, so c² = a² + b² |
| Obtuse angle | If C > 90°, cos(C) < 0, so c² > a² + b² |
Common Applications
- Solving SSS triangles: finding all angles when only side lengths are known, which the law of sines alone cannot do
- Solving SAS triangles: finding the third side and remaining angles when two sides and the included angle are known
- Navigation and GPS: computing distances between points when direct measurement is impossible but distances from two reference points and the included angle are known
- Physics and engineering: calculating resultant vectors using the parallelogram law, where the magnitude of the resultant depends on the angle between two vectors
- Computer graphics: determining polygon geometry and performing collision detection in 3D space where triangle meshes are the fundamental building block
The law of cosines extends the Pythagorean theorem to any triangle. When C = 90 degrees, the formula reduces to the familiar a² + b² = c².
Understanding the Concept
The law of cosines is one of the two fundamental tools (alongside the law of sines) for solving arbitrary triangles. It can be viewed as a generalization of the Pythagorean theorem that includes a correction term for non-right triangles. The formula c² = a² + b² - 2ab·cos(C) expresses the length of side c in terms of sides a, b and the included angle C between them. When angle C is 90 degrees, cos(90°) = 0 and the formula simplifies to c² = a² + b², which is the Pythagorean theorem. When angle C is acute (less than 90 degrees), cos(C) > 0 and the correction term is positive, making c² less than a² + b². When angle C is obtuse (greater than 90 degrees), cos(C) < 0 and the correction term becomes negative, making c² greater than a² + b². This behavior matches the geometric intuition: an obtuse angle "stretches" the opposite side. The law of cosines can be rearranged to solve for angles when all three sides are known: cos(C) = (a² + b² - c²)/(2ab). This rearrangement is the key to solving SSS triangles. The formula can be cyclically permuted for any vertex: a² = b² + c² - 2bc·cos(A) and b² = a² + c² - 2ac·cos(B). The law of cosines has a rich geometric interpretation. It can be derived by dropping an altitude from vertex A to side a, creating two right triangles, and applying the Pythagorean theorem to each. The distance from the foot of the altitude to vertex B is c·cos(B), and to vertex C is b·cos(C). These projections sum to the full side length a, giving the relationship a = b·cos(C) + c·cos(B), which is known as the projection formula and is equivalent to the law of cosines. Numerically, the law of cosines is well-behaved for most triangles but can be less accurate for very flat triangles (where angles are near 0 or 180 degrees) due to floating-point precision in the arccosine function. In such cases, the law of sines may give more accurate angle results after the first angle is determined.
Frequently Asked Questions
Sources & References
Related Calculators
Reviews
No reviews yet. Be the first to share your experience with Law of Cosines Calculator — Side & Angle Solver.
Write a Review
