Law of Cosines Calculator: Solve Triangles


Law of Cosines Calculator

Solve for unknown sides and angles in any triangle using the Law of Cosines.



Length of side opposite angle A. Units: Any consistent length unit (e.g., cm, m, inches).



Length of side opposite angle B. Units: Same as Side A.



Length of side opposite angle C. Units: Same as Side A.



Angle opposite Side A. Units: Degrees (°).



Angle opposite Side B. Units: Degrees (°).



Angle opposite Side C. Units: Degrees (°).


Calculation Results

Side A:

Side B:

Side C:

Angle A: (°)

Angle B: (°)

Angle C: (°)

Triangle Type:

Sum of Angles: (°)

Sum of Sides:

Formulas Used (Law of Cosines):
c² = a² + b² – 2ab cos(C)
a² = b² + c² – 2bc cos(A)
b² = a² + c² – 2ac cos(B)
Law of Sines for Angles: sin(A)/a = sin(B)/b = sin(C)/c
Angle Sum Property: A + B + C = 180°
Property Value Unit
Side A Length
Side B Length
Side C Length
Angle A Degrees
Angle B Degrees
Angle C Degrees
Triangle Properties and Units

Understanding the Law of Cosines Calculator

What is the Law of Cosines?

The Law of Cosines is a fundamental theorem in trigonometry that establishes a relationship between the lengths of the sides and the cosines of the angles of any triangle. It’s a crucial tool for solving triangles when you don’t have a right angle, particularly when you have specific combinations of known sides and angles. This calculator helps you apply that law efficiently.

Who should use this calculator? Students learning trigonometry, engineers, architects, surveyors, navigators, and anyone dealing with non-right triangles will find this tool invaluable. It simplifies complex calculations, reducing the chance of manual errors.

Common Misunderstandings: People often confuse the Law of Cosines with the Law of Sines. While both are used to solve triangles, they apply to different scenarios. The Law of Cosines is best used when you know:

  • All three sides (SSS)
  • Two sides and the included angle (SAS)

The Law of Sines is typically used when you know two angles and one side (AAS or ASA), or two sides and a non-included angle (SSA, though this can sometimes lead to ambiguous cases).

Law of Cosines Formula and Explanation

The Law of Cosines provides three main equations, relating the sides (a, b, c) and their opposite angles (A, B, C) in any triangle:

  • To find side c: c² = a² + b² – 2ab cos(C)
  • To find side a: a² = b² + c² – 2bc cos(A)
  • To find side b: b² = a² + c² – 2ac cos(B)

From these, we can rearrange to solve for angles:

  • cos(C) = (a² + b² – c²) / 2ab => C = arccos((a² + b² – c²) / 2ab)
  • cos(A) = (b² + c² – a²) / 2bc => A = arccos((b² + c² – a²) / 2bc)
  • cos(B) = (a² + c² – b²) / 2ac => B = arccos((a² + c² – b²) / 2ac)

The calculator handles these calculations automatically. It also utilizes the Angle Sum Property (A + B + C = 180°) and the Law of Sines (sin(A)/a = sin(B)/b = sin(C)/c) to find all unknown values and verify the triangle’s properties.

Variables Table

Variable Meaning Unit Typical Range
a, b, c Length of triangle sides Any consistent length unit (e.g., meters, feet, inches) Positive values. Must satisfy triangle inequality (sum of any two sides > third side).
A, B, C Measures of angles opposite sides a, b, c respectively Degrees (°), radians (rad) – calculator uses Degrees (0°, 180°). Sum of A, B, C must be 180°.
Variables used in the Law of Cosines

Practical Examples

Let’s explore a couple of scenarios where the Law of Cosines calculator is useful:

Example 1: Two Sides and Included Angle (SAS)

Imagine you are designing a triangular garden plot. You know two sides are 8 meters and 10 meters long, and the angle between them is 60°.

  • Inputs: Side A = 8 m, Side B = 10 m, Angle C = 60°
  • Calculator Action: The calculator uses c² = a² + b² – 2ab cos(C) to find Side C. Then, it uses the rearranged Law of Cosines to find Angles A and B.
  • Results: Side C ≈ 9.43 m, Angle A ≈ 36.87°, Angle B ≈ 83.13°

Example 2: Three Sides Known (SSS)

A surveyor measures the boundaries of a property. The distances are 150 feet, 200 feet, and 250 feet.

  • Inputs: Side A = 150 ft, Side B = 200 ft, Side C = 250 ft
  • Calculator Action: The calculator uses the rearranged Law of Cosines to find each angle (A, B, C). For instance, cos(A) = (b² + c² – a²) / 2bc.
  • Results: Angle A ≈ 36.87°, Angle B ≈ 53.13°, Angle C = 90° (This is a right triangle!)

How to Use This Law of Cosines Calculator

Using the calculator is straightforward:

  1. Identify Known Values: Determine which sides and angles of your triangle are known. The Law of Cosines requires either SSS (all three sides) or SAS (two sides and the angle directly between them).
  2. Input Values: Enter the known lengths into the ‘Side A’, ‘Side B’, and ‘Side C’ fields. Ensure you use consistent units (e.g., all in meters or all in feet). Enter the known angles (in degrees) into the ‘Angle A’, ‘Angle B’, or ‘Angle C’ fields.
  3. Leave Unknowns Blank: Do not enter values for the sides or angles you need to find. The calculator will automatically detect these.
  4. Click Calculate: Press the “Calculate” button.
  5. Interpret Results: The calculator will display the lengths of the unknown sides and the measures of the unknown angles. It will also indicate the type of triangle and verify the angle sum.
  6. Units: Pay close attention to the units. If you input sides in meters, the calculated unknown side will also be in meters. Angles are always calculated and displayed in degrees (°).

Key Factors Affecting Triangle Solutions

Several factors influence the results when solving triangles, especially concerning the Law of Cosines:

  1. Triangle Inequality Theorem: The sum of the lengths of any two sides of a triangle must be greater than the length of the third side. If this condition isn’t met by your inputs, a valid triangle cannot be formed.
  2. Angle Units: Ensure you are consistently using degrees or radians. This calculator specifically uses degrees for angle inputs and outputs.
  3. Included Angle (SAS): For the SAS case, the angle must be the one *between* the two given sides. Providing an angle opposite one of the sides requires a different approach (potentially Law of Sines, with careful handling of ambiguous cases).
  4. Precision of Inputs: The accuracy of your input values directly impacts the accuracy of the calculated results. Minor errors in measurement can lead to noticeable differences in computed angles or sides.
  5. Calculator Limitations: While powerful, calculators rely on trigonometric functions. Very small or very large angles, or triangles with extreme side ratios, might introduce floating-point inaccuracies inherent in computer calculations.
  6. Cosine Function Range: The cosine function’s output is between -1 and 1. The calculation `(a² + b² – c²) / 2ab` must result in a value within this range for a valid angle to exist. Values outside this range indicate an impossible triangle configuration.

Frequently Asked Questions (FAQ)

Q1: Can the Law of Cosines solve any triangle?

A: Yes, the Law of Cosines can be used to solve any triangle (find all unknown sides and angles) provided you have one of the following sets of information: Side-Side-Side (SSS), or Side-Angle-Side (SAS).

Q2: What’s the difference between the Law of Cosines and the Law of Sines?

A: The Law of Cosines is used for SSS and SAS cases. The Law of Sines is used for Angle-Angle-Side (AAS), Angle-Side-Angle (ASA), and sometimes Side-Side-Angle (SSA). The SSA case with the Law of Sines can be ambiguous (one or two solutions).

Q3: My calculated angle is negative or greater than 180°. What’s wrong?

A: This usually indicates an error in your input values, such as violating the triangle inequality theorem, or potentially using the wrong formula rearrangement. Ensure your inputs form a valid triangle.

Q4: Does the unit of measurement for sides matter?

A: Yes, but only in terms of consistency. If you measure Side A in meters, Side B must also be in meters for the Law of Cosines calculation to be correct. The resulting unknown side will then also be in meters. The angles are always in degrees (or radians, if specified).

Q5: How accurate are the results from this calculator?

A: The results are generally highly accurate, limited only by the precision of standard floating-point arithmetic in JavaScript. For most practical purposes, the accuracy is more than sufficient.

Q6: What if the triangle is a right triangle?

A: The Law of Cosines works perfectly for right triangles too! If C = 90°, then cos(C) = 0, and the formula simplifies to c² = a² + b², which is the Pythagorean theorem.

Q7: Can I input angles in radians?

A: This calculator is designed to accept and output angles in degrees (°). If your angles are in radians, you’ll need to convert them to degrees before inputting them.

Q8: What does “Triangle Type” mean in the results?

A: This indicates whether the triangle is Scalene (all sides/angles different), Isosceles (two sides/angles equal), Equilateral (all sides/angles equal), or Right (one angle is 90°).


Leave a Reply

Your email address will not be published. Required fields are marked *