Law of Cosines Calculator

Calculate missing sides and angles in any triangle using the Law of Cosines formula.

Law of Cosines Formulas:

c² = a² + b² - 2ab·cos(C)

b² = a² + c² - 2ac·cos(B)

a² = b² + c² - 2bc·cos(A)

cos(C) = (a² + b² - c²) / (2ab)

Where a, b, c are the sides and A, B, C are the angles opposite to them

This will calculate side c and angles A and B

Understanding the Law of Cosines

The Law of Cosines is a formula relating the sides and angles of a triangle. It's particularly useful for solving triangles when you have certain pieces of information but not others. Unlike the Pythagorean Theorem, which only works for right triangles, the Law of Cosines works for any triangle.

The Formula

The Law of Cosines can be expressed in three equivalent forms, depending on which side or angle you're solving for:

c² = a² + b² - 2ab·cos(C)

b² = a² + c² - 2ac·cos(B)

a² = b² + c² - 2bc·cos(A)

These formulas can be rearranged to find angles:

cos(C) = (a² + b² - c²) / (2ab)

cos(B) = (a² + c² - b²) / (2ac)

cos(A) = (b² + c² - a²) / (2bc)

Where a, b, and c are the sides of the triangle, and A, B, and C are the angles opposite to those sides.

When to Use the Law of Cosines

The Law of Cosines is particularly useful in the following scenarios:

  • Side-Angle-Side (SAS): When you know two sides and the included angle
  • Side-Side-Side (SSS): When you know all three sides
  • Angle-Side-Angle (ASA): When you know two angles and the included side (after using the fact that angles in a triangle sum to 180°)

Special Cases and Limitations

  • Right Triangles: When one angle is 90°, the Law of Cosines simplifies to the Pythagorean Theorem
  • Triangle Inequality: For a valid triangle, the sum of the lengths of any two sides must be greater than the length of the remaining side
  • Ambiguous Case (SSA): When you know two sides and a non-included angle, there might be zero, one, or two possible triangles (the ambiguous case)

Practical Applications

The Law of Cosines has numerous practical applications:

  • Navigation and Surveying: Calculating distances and angles in land surveys
  • Engineering: Analyzing forces and structures in non-perpendicular arrangements
  • Physics: Resolving vectors in two and three dimensions
  • Astronomy: Calculating distances between celestial objects
  • Architecture: Designing structures with non-right angles

How to Use This Calculator

  1. Select the calculation type based on what information you have:
    • Side-Angle-Side (SAS): Enter two sides and the included angle
    • Side-Side-Side (SSS): Enter all three sides
    • Angle-Side-Angle (ASA): Enter two angles and the included side
  2. Enter the required values in the appropriate fields
  3. Click "Calculate Triangle" to see the results
  4. The calculator will display all remaining sides and angles, along with a visual representation of the triangle
  5. Use the "Clear All" button to reset the calculator

Frequently Asked Questions

What's the difference between the Law of Cosines and the Pythagorean Theorem?

The Pythagorean Theorem (a² + b² = c²) is actually a special case of the Law of Cosines where one of the angles is 90°. When angle C = 90°, cos(C) = 0, so the Law of Cosines formula c² = a² + b² - 2ab·cos(C) simplifies to c² = a² + b². The Law of Cosines is more general and works for any triangle, not just right triangles.

When should I use the Law of Cosines vs. the Law of Sines?

Use the Law of Cosines when you have SAS (two sides and the included angle) or SSS (three sides). Use the Law of Sines when you have AAS (two angles and a non-included side) or ASA (two angles and the included side). For SSA (two sides and a non-included angle), you might need both laws and should be aware of the ambiguous case where multiple solutions may exist.

How accurate is this calculator?

This calculator uses standard trigonometric functions and provides results with high precision. However, very small or very large values may lead to rounding errors. If you're working on a critical application requiring extreme precision, always verify results with alternative methods.

Can the Law of Cosines be used in three dimensions?

The Law of Cosines as presented here applies to planar (2D) triangles. For 3D problems, you would typically decompose the problem into component triangles or use vector mathematics. However, there are generalizations of the Law of Cosines for spherical triangles used in navigation and astronomy.

What happens if I enter values that don't form a valid triangle?

The calculator checks for the triangle inequality theorem (the sum of any two sides must be greater than the third side) and other constraints like angles summing to 180°. If your inputs don't satisfy these conditions, you'll receive an error message explaining why a valid triangle cannot be formed with those values.