Law of Cosines Calculator

Enter two sides and the included angle of a triangle to find the missing side, both remaining angles, and the triangle's area using c² = a² + b² − 2ab·cos(C).

Quick Facts

Law of Cosines
c² = a² + b² − 2ab·cos(C)
Relates one side to the other two sides and the angle between them.
Solving for an angle
cos(C) = (a² + b² − c²) / (2ab)
Rearranged form used to find angles when all three sides (SSS) are known.
Right-triangle case
C = 90° → c² = a² + b²
Reduces to the Pythagorean theorem when the included angle is 90°.

Your Results

Calculated
Side c
-
c = √(a² + b² − 2ab·cos C)
Angle A
-
Opposite side a
Angle B
-
Opposite side b
Triangle Area
-
Area = ½·a·b·sin(C)

Ready

Enter two sides and the included angle, then press Calculate.

How the Law of Cosines works

The Law of Cosines generalizes the Pythagorean theorem to work with any triangle, not just right triangles. For a triangle with sides a, b, and c, where angle C is the angle opposite side c (and included between sides a and b), the Law of Cosines states c² = a² + b² − 2ab·cos(C). This calculator uses that relationship to find a missing side from two sides and their included angle (SAS), then derives the remaining two angles and the triangle's area from the result.

Formula and derivation

The formula comes from dropping a perpendicular from one vertex to the opposite side and applying the Pythagorean theorem to the two right triangles that result, then substituting cos(C) for the ratio that appears from the adjacent leg. When C = 90°, cos(C) = 0 and the formula collapses to the familiar c² = a² + b², confirming the Law of Cosines is a true generalization rather than a separate rule.

Solving a triangle: SAS and SSS

Given two sides and the included angle (SAS), enter a, b, and angle C to solve for side c directly. Once c is known, the same formula can be rearranged to solve for either remaining angle: cos(A) = (b² + c² − a²) / (2bc) and cos(B) = (a² + c² − b²) / (2ac); taking the inverse cosine of each gives angle A and angle B. The same rearranged formula, cos(C) = (a² + b² − c²) / (2ab), is what you would use if instead you started with all three sides (SSS) and needed to find an angle.

Common mistakes

  • Using the wrong angle: angle C must be the angle between sides a and b (the included angle) — using a non-included angle gives an incorrect side c.
  • Mixing degrees and radians: make sure the angle unit you select matches how you measured the angle, since cos(60) and cos(60°) are very different numbers.
  • Invalid triangles: the included angle must be strictly between 0° and 180°, and all three sides must be positive, or no triangle exists.

Real-world applications

  • Surveying and navigation use the Law of Cosines to find distances between points when direct measurement is impossible but two legs and a turning angle are known.
  • Engineering and construction use it to check truss and framing geometry where triangles are not right triangles.
  • Physics uses the same formula (as the law of cosines for vectors) to find the magnitude of a resultant vector from two vectors and the angle between them.
  • Navigation and GPS triangulation use it alongside the Law of Sines to fully solve triangles formed by known landmarks or waypoints.

Frequently Asked Questions

What is the Law of Cosines formula?
For a triangle with sides a, b, c and the angle C opposite side c, the Law of Cosines states c² = a² + b² − 2ab·cos(C). It generalizes the Pythagorean theorem to any triangle, not just right triangles.
When should I use the Law of Cosines instead of the Law of Sines?
Use the Law of Cosines when you know two sides and the included angle (SAS) or all three sides (SSS). Use the Law of Sines instead when you know two angles and a side (AAS/ASA) or two sides and a non-included angle (SSA).
How do I find a missing angle if I know all three sides (SSS)?
Rearrange the Law of Cosines to solve for the angle: cos(C) = (a² + b² − c²) / (2ab), then take the inverse cosine. The same pattern works for angles A and B by rotating which side is isolated.
Does the Law of Cosines work for right triangles?
Yes. When the included angle C is 90°, cos(C) = 0, so the formula reduces to c² = a² + b², which is the Pythagorean theorem. The Law of Cosines is a generalization that also works for acute and obtuse triangles.