Skip to main content
math

Law of Cosines Calculator

Calculate the missing side or angle of a triangle using the Law of Cosines: c² = a² + b² − 2ab cos(C).

Reviewed by Chase FloiedUpdated

This free online law of cosines calculator provides instant results with no signup required. All calculations run directly in your browser — your data is never sent to a server. Enter your values below and see results update in real time as you type. Perfect for everyday calculations, homework, or professional use.

The angle between sides a and b

Results

Side c

6.245 units

How to Use This Calculator

1

Enter your input values

Fill in all required input fields for the Law of Cosines Calculator. Most fields include unit selectors so you can work in your preferred unit system — metric or imperial, whichever matches your problem.

2

Review your inputs

Double-check that all values are correct and that you have selected the right units for each field. Incorrect units are the most common source of calculation errors and can produce results that are off by factors of 2, 10, or more.

3

Read the results

The Law of Cosines Calculator instantly computes the output and displays results with units clearly labeled. All calculations happen in your browser — no loading time and no data sent to a server.

4

Explore parameter sensitivity

Try adjusting individual input values to see how the output changes. This is a quick and effective way to develop intuition about how different parameters influence the result and to identify which inputs have the largest effect.

Formula Reference

Law of Cosines Calculator Formula

See calculator inputs for the governing equation

Variables: All variables and their units are labeled in the calculator interface above. Input fields accept values in multiple unit systems — select your preferred unit from the dropdown next to each field.

When to Use This Calculator

  • Use the Law of Cosines Calculator when you need a quick mathematical result without writing out all the steps manually, saving time on repetitive calculations.
  • Use it to verify hand calculations on tests or assignments and catch arithmetic mistakes.
  • Use it when teaching or explaining mathematical concepts to others, demonstrating how changing inputs affects the result.
  • Use it to explore the behavior of mathematical functions across a range of inputs.

About This Calculator

The Law of Cosines Calculator is a free mathematical calculation tool for students, educators, and professionals who need quick, reliable results. Calculate the missing side or angle of a triangle using the Law of Cosines: c² = a² + b² − 2ab cos(C). The underlying algorithms implement well-established mathematical formulas and numerical methods. Results are computed instantly in the browser. This tool is useful for learning, verification of hand calculations, and rapid exploration of mathematical relationships. All computation happens locally — no data is sent to a server.

About Law of Cosines Calculator

The Law of Cosines is a generalization of the Pythagorean theorem that works for any triangle, not just right triangles. It states that c² = a² + b² − 2ab cos(C), where C is the angle between sides a and b, and c is the side opposite angle C. When C = 90°, cos(C) = 0 and the formula reduces to the Pythagorean theorem. The Law of Cosines can be used to find a missing side when two sides and the included angle are known (SAS), or to find an angle when all three sides are known (SSS). It is fundamental in surveying, navigation, physics, and engineering. This calculator finds the third side given two sides and the included angle. The law was first stated by Euclid in a geometric form and later generalized using trigonometric notation.

The Math Behind It

The Law of Cosines can be derived using coordinate geometry. Place vertex C at the origin, side a along the positive x-axis, then vertex B is at (a, 0) and vertex A is at (b cos(C), b sin(C)). The distance from A to B is c = √((a − b cos(C))² + (b sin(C))²) = √(a² − 2ab cos(C) + b²cos²(C) + b²sin²(C)) = √(a² + b² − 2ab cos(C)). The law can be rearranged to find angles: cos(C) = (a² + b² − c²)/(2ab). This is useful for the SSS case. The formula also has versions for the other two sides: a² = b² + c² − 2bc cos(A) and b² = a² + c² − 2ac cos(B). In spherical geometry, the Law of Cosines becomes cos(c) = cos(a)cos(b) + sin(a)sin(b)cos(C), where the sides are measured as angles subtended at the center. The Stewart's theorem a²n + b²m − c²mn = d²(m + n) generalizes the Law of Cosines to cevians.

Formula Reference

Law of Cosines

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

Variables: a, b = known sides; C = included angle; c = opposite side

Worked Examples

Example 1: Surveying a plot

Two sides measure 100 m and 80 m with a 45° angle between them.

Step 1:c² = 100² + 80² − 2(100)(80)cos(45°)
Step 2:c² = 10000 + 6400 − 16000 × 0.7071
Step 3:c² = 16400 − 11314 = 5086
Step 4:c = √5086

c ≈ 71.32 m

Common Mistakes & Tips

  • !Using degrees instead of radians in a calculator set to radian mode (or vice versa).
  • !Forgetting the minus sign in the formula (it is −2ab cos(C)).
  • !Applying the Law of Cosines when the Law of Sines would be simpler and sufficient.

Related Concepts

Used in These Calculators

Calculators that build on or apply the concepts from this page:

Frequently Asked Questions

When should I use the Law of Cosines instead of the Law of Sines?

Use the Law of Cosines for SAS (two sides and included angle) or SSS (all three sides) cases. The Law of Sines is better for ASA, AAS, and some SSA cases.

Can the result be negative under the square root?

No, as long as the inputs form a valid triangle. The expression a² + b² − 2ab cos(C) is always non-negative for 0° < C < 180°.