Law of Cosines Calculator
Solve triangles from three sides (SSS) or two sides and the included angle (SAS). Returns all missing parts with step-by-step working.
📊 What is the Law of Cosines?
The Law of Cosines is a fundamental theorem of trigonometry that relates the lengths of the three sides of any triangle to the cosine of one of its angles. The full statement is:
- c² = a² + b² − 2ab cos(C)
- a² = b² + c² − 2bc cos(A)
- b² = a² + c² − 2ac cos(B)
where a, b, c are side lengths and A, B, C are the angles opposite to those respective sides.
The Law of Cosines is a direct generalization of the Pythagorean theorem: when angle C equals 90°, cos(C) = 0, and the formula reduces to c² = a² + b². For acute angles (C < 90°), the correction term is negative, making c smaller than the Pythagorean hypotenuse; for obtuse angles (C > 90°), the correction term is positive, making c larger.
The formula was known to ancient Greek mathematicians and is sometimes called the cosine rule in British usage. It appears explicitly in Euclid’s Elements as Propositions II.12 and II.13, though without the modern trigonometric notation. The modern form using cosines was developed in the 15th and 16th centuries.
📐 Formula
The primary form used for finding a missing side (SAS mode):
c² = a² + b² − 2ab cos(C)
Rearranged to find a missing angle from three known sides (SSS mode):
cos(A) = (b² + c² − a²) / (2bc)
cos(B) = (a² + c² − b²) / (2ac)
cos(C) = (a² + b² − c²) / (2ab)
Variables:
- a, b, c - the three side lengths of the triangle
- A - angle opposite side a
- B - angle opposite side b
- C - angle opposite side c (the included angle in SAS mode)
Area formula (used after the triangle is fully solved): Area = ½ × a × b × sin(C)
📖 How to Use
Steps to Calculate
💡 Example Calculations
Example 1 — SSS: Find All Angles from Three Sides
Triangle with sides a = 7, b = 10, c = 8
Example 2 — SAS: Find Missing Side and Angles
Triangle with a = 5, b = 8, C = 60°
Example 3 — SAS: Obtuse Included Angle
Triangle with a = 6, b = 9, C = 120°
❓ Frequently Asked Questions
🔗 Related Calculators
What is the Law of Cosines?
The Law of Cosines states that for any triangle with sides a, b, c and opposite angles A, B, C: c² = a² + b² − 2ab cos(C). You can rearrange it for any side: a² = b² + c² − 2bc cos(A) and b² = a² + c² − 2ac cos(B). It generalizes the Pythagorean theorem to all triangles - when C = 90°, cos(C) = 0 and the formula reduces to c² = a² + b².
When should I use the Law of Cosines vs the Law of Sines?
Use the Law of Cosines for SSS (all three sides known - find all angles) and SAS (two sides and the included angle - find the third side). Use the Law of Sines for SAA/AAS (one side and two angles) and SSA (two sides and a non-included angle, which is the ambiguous case). The mnemonic: if you have a complete side-angle pair plus one more value, the Law of Sines applies; otherwise, use the Law of Cosines.
How do you find an angle using the Law of Cosines?
Rearrange the formula to solve for the cosine of the angle: cos(A) = (b² + c² − a²) / (2bc). Then take the inverse cosine: A = arccos((b² + c² − a²) / (2bc)). This always returns a unique angle between 0° and 180°, so there is no ambiguous case with SSS - each set of valid sides gives exactly one triangle shape.
What is the triangle inequality and why does it matter?
The triangle inequality states that the sum of any two sides must be greater than the third: a + b > c, a + c > b, and b + c > a. If this is violated, no triangle exists. In the Law of Cosines formula, violating the triangle inequality causes the cosine to exceed 1 in absolute value, making the arccos undefined. This calculator checks for this and reports an error.
How does the Law of Cosines relate to the Pythagorean theorem?
The Pythagorean theorem (a² + b² = c²) is a special case of the Law of Cosines when the angle C = 90°. Since cos(90°) = 0, the term 2ab cos(C) vanishes, leaving c² = a² + b². For obtuse angles (C > 90°), cos(C) < 0, so c² > a² + b² - the side opposite the obtuse angle is longer than a Pythagorean hypotenuse would be. For acute triangles, c² < a² + b².
What is the SAS (two sides and included angle) configuration?
SAS means you know two sides and the angle between them (the included angle). For example: a = 5, b = 8, C = 60° (where C is the angle between sides a and b). The Law of Cosines finds the third side directly: c² = 5² + 8² − 2(5)(8) cos(60°) = 25 + 64 − 40 = 49, so c = 7. Once c is known, the remaining angles follow from further applications of the cosine rule.
Can the Law of Cosines handle obtuse triangles?
Yes - the Law of Cosines works for all triangles: acute, right, and obtuse. For an obtuse angle C (90° < C < 180°), cos(C) is negative, which makes the term −2ab cos(C) positive, correctly producing a larger third side. The formula gives real, valid results for any triangle satisfying the triangle inequality, regardless of whether angles are acute or obtuse.
What is the difference between SSS and SAS modes?
SSS mode (three sides) uses cos(A) = (b² + c² − a²) / (2bc) to find each angle from the known sides - no ambiguity. SAS mode (two sides and included angle) uses c² = a² + b² − 2ab cos(C) to find the missing side, then finds the remaining angles. SSS solves for angles; SAS solves for the unknown side first, then angles.
How is the triangle area computed?
The calculator uses the formula Area = ½ × a × b × sin(C), where a and b are two sides and C is the included angle. For SSS mode, C is derived first from the cosine rule, then used in the area formula. This gives the exact area from any complete triangle solution. The formula works because ½ × base × height = ½ × a × (b sin C) when C is the angle at the vertex between sides a and b.
How do you verify a Law of Cosines result?
Check three things: (1) all three angles sum to 180°, (2) all sides and angles are positive, (3) the Pythagorean-like check c² ≈ a² + b² − 2ab cos(C) holds for the computed values. You can also verify with the Law of Sines: a/sin(A) should equal b/sin(B) and c/sin(C). A consistent sine ratio confirms the solution.
What is the cosine rule used for in real life?
The Law of Cosines is used extensively in navigation (finding the distance between two GPS points given bearings), surveying (triangulating an inaccessible point), structural engineering (analyzing force triangles), and computer graphics (computing angles in 3D meshes). Any scenario involving three known measurements of a triangle - sides or angles - can be solved with it.