Updated on April 21st, 2026

Law of Cosines Calculator

Created By Jehan Wadia

SAS: Enter two sides and the included angle. The Law of Cosines will compute the unknown third side: c² = a² + b² − 2ab·cos(C).
Units are for labeling purposes only

(will be calculated)
(included angle)
Triangle Solution
Step-by-Step Solution

Introduction

The Law of Cosines is a formula that helps you find missing sides or angles in any triangle. It works for all triangles, not just right triangles. The formula looks like this: c² = a² + b² − 2ab·cos(C). You use it when you know two sides and the angle between them, or when you know all three sides and need to find an angle. This Law of Cosines Calculator does the math for you. Just enter the values you know, and it will solve for the missing piece. It saves time and helps you avoid mistakes with tricky calculations.

How to Use Our Law of Cosines Calculator

Enter your known side lengths and angles to solve for the missing parts of any triangle. The calculator will return all sides, angles, area, perimeter, triangle classification, and a step-by-step solution with a diagram.

Calculation Mode: Choose one of three modes at the top. Select Find a Side (SAS) if you know two sides and the angle between them. Select Find an Angle (SSS) if you know all three sides. Select Solve Whole Triangle to find every missing measurement at once using either SAS or SSS input.

Side a: Enter the length of side a, which is the side across from angle A. This value must be a positive number.

Side b: Enter the length of side b, which is the side across from angle B. This value must be a positive number.

Side c: Enter the length of side c, which is the side across from angle C. In SAS mode, this field is calculated for you automatically.

Angle A: Enter the measure of angle A, which sits across from side a. In SAS mode, this angle is computed from the results.

Angle B: Enter the measure of angle B, which sits across from side b. In SAS mode, this angle is computed from the results.

Angle C: Enter the measure of angle C, which sits across from side c. In SAS mode, this is the included angle between sides a and b.

Angle Unit: Pick whether your angles are in degrees or radians. The calculator will use this setting for all angle inputs and outputs.

Length Unit: Choose a length unit such as meters, feet, or inches. This is used only for labeling your results and does not change the math.

Precision: Select how many decimal places or significant figures you want in your answers, from 2 decimal places up to 7 significant figures.

Solve for Angle (SSS mode only): When using Find an Angle mode, pick which angle (A, B, or C) you want the calculator to highlight in the step-by-step solution. All three angles are still computed regardless of your choice.

Calculate / Reset: Click Calculate to run the solver, or click Reset to clear all fields and return to the default SAS example. Results will include a labeled triangle diagram, a verification that the angles add up to 180°, and a full breakdown of every step used in the solution.

Understanding the Law of Cosines

The Law of Cosines is a formula in geometry that connects the three sides of a triangle to one of its angles. It works for any triangle, not just right triangles. The standard formula looks like this:

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

Here, a, b, and c are the three sides of a triangle, and C is the angle directly across from side c. If you know two sides and the angle between them, you can find the third side. If you know all three sides, you can rearrange the formula to find any angle.

When Do You Use the Law of Cosines?

You use the Law of Cosines in two main situations:

  • SAS (Side-Angle-Side): You know two sides and the angle between them, and you need to find the missing third side.
  • SSS (Side-Side-Side): You know all three sides and need to find an angle. In this case, you rearrange the formula to: cos(C) = (a² + b² − c²) / (2ab).

How It Relates to the Pythagorean Theorem

The Law of Cosines is actually a more general version of the Pythagorean theorem. When angle C equals exactly 90°, the term 2ab · cos(90°) becomes zero because cos(90°) = 0. That leaves you with c² = a² + b², which is the Pythagorean theorem. So the Pythagorean theorem is really just a special case of the Law of Cosines that only works for right triangles. If you're working specifically with right triangles, our Right Triangle Calculator can handle those cases directly.

Solving an Entire Triangle

Once you find the missing side or angle using the Law of Cosines, you can solve the rest of the triangle. After computing the third side in an SAS problem, you can apply the Law of Cosines again (in its inverse form) to find a second angle. The third angle is then found using the angle sum property: the three angles in every triangle always add up to 180°. With all three sides and all three angles known, you can also calculate the triangle's area using Heron's formula — or try our dedicated Triangle Area Calculator for more area methods — and its perimeter by adding the sides together.

Triangle Classification

Knowing all sides and angles also lets you classify a triangle. A triangle is acute if every angle is less than 90°, right if one angle equals 90°, and obtuse if one angle is greater than 90°. Based on side lengths, it is equilateral if all three sides are equal, isosceles if exactly two sides are equal, and scalene if no sides are equal.

Important Rules to Remember

Not every combination of numbers forms a real triangle. The triangle inequality states that the sum of any two sides must be greater than the third side. Also, the included angle must be between 0° and 180° (not including those endpoints). If these conditions are not met, no valid triangle exists.

Related Geometry Tools

If your problem involves finding the distance between two points, our Distance Calculator can help, while the Midpoint Calculator finds the center point between two coordinates. For working with other shapes, check out the Hexagon Calculator, Circle Area Calculator, or volume tools like the Sphere Volume Calculator, Cylinder Volume Calculator, and Cone Volume Calculator. If you need to compute arc measurements, the Arc Length Calculator is another useful companion. For problems involving slope or rate of change in coordinate geometry, the Slope Calculator and Rate of Change Calculator are worth exploring as well.


Frequently Asked Questions

What is the Law of Cosines formula?

The Law of Cosines formula is c² = a² + b² − 2ab·cos(C). In this formula, a, b, and c are the three sides of a triangle, and C is the angle opposite side c. You can rearrange it to solve for any side or any angle depending on what information you already have.

What is the difference between SAS and SSS mode?

SAS (Side-Angle-Side) means you know two sides and the angle between them. The calculator uses this to find the missing third side. SSS (Side-Side-Side) means you know all three side lengths and need to find an angle. Pick the mode that matches the information you already have.

Can I use the Law of Cosines on a right triangle?

Yes. The Law of Cosines works on every triangle, including right triangles. When the included angle is 90°, cos(90°) equals zero, so the formula simplifies to c² = a² + b², which is the Pythagorean theorem. So a right triangle is just a special case.

How does the calculator find the area of the triangle?

After finding all three sides, the calculator uses Heron's formula. First it computes the semi-perimeter: s = (a + b + c) / 2. Then the area equals √(s(s−a)(s−b)(s−c)). This method only needs the three side lengths.

Why does the calculator say my sides do not form a valid triangle?

This happens when your side lengths break the triangle inequality rule. The sum of any two sides must be greater than the third side. For example, sides of 1, 2, and 10 do not work because 1 + 2 = 3, which is less than 10. Check your numbers and try again.

Can I switch between degrees and radians?

Yes. Use the Angle Unit dropdown to choose degrees or radians. The calculator applies your choice to all angle inputs and outputs. Make sure your angle values match the unit you selected, or you will get wrong results.

How do I find an angle when I know all three sides?

Use the Find an Angle (SSS) mode. Enter all three side lengths, then pick which angle you want to solve for. The calculator rearranges the formula to cos(C) = (a² + b² − c²) / (2ab) and takes the inverse cosine to get the angle.

What does the verification step check?

The verification step adds up all three angles (A + B + C) and checks that the total is 180° (or π radians). Every valid triangle must have angles that sum to exactly 180°. If the sum is off, there may be a rounding issue or an input error.

Does the length unit affect the calculation?

No. The length unit is only for labeling your results. Whether you pick meters, feet, inches, or no unit at all, the math stays the same. Just make sure all your side lengths use the same unit before you enter them.

What do acute, obtuse, and right mean in the triangle classification?

Acute means all three angles are less than 90°. Right means one angle is exactly 90°. Obtuse means one angle is greater than 90°. The calculator figures this out automatically after solving all the angles.

What do scalene, isosceles, and equilateral mean?

Scalene means all three sides have different lengths. Isosceles means exactly two sides are the same length. Equilateral means all three sides are equal. The calculator checks the side lengths and tells you which type your triangle is.

Why must the included angle be between 0° and 180°?

An angle of 0° or 180° would make the triangle collapse into a straight line or a single point. A real triangle needs every angle to be strictly greater than 0° and strictly less than 180°. If you enter an angle outside this range, the calculator will show an error.

How does the Solve Whole Triangle mode work?

This mode finds every missing measurement at once. Pick SAS or SSS input depending on what you know. The calculator first uses the Law of Cosines to find the missing side or angles, then computes everything else including the remaining angles, area, perimeter, and triangle type.

What precision setting should I choose?

For most homework and general use, 4 decimal places or 6 significant figures works well. If you need extra accuracy for engineering or science, choose a higher setting. If you want cleaner numbers for quick estimates, choose 2 decimal places or 3 significant figures.

Can the Law of Cosines be used for non-triangle problems?

The Law of Cosines applies specifically to triangles. However, many real-world problems can be broken into triangles. For example, finding the distance between two points with a known angle, navigation problems, or determining forces in physics all use the Law of Cosines by forming a triangle from the given information.


Related Calculators

Midpoint Calculator

Visit Midpoint Calculator

Distance Calculator

Visit Distance Calculator

Right Triangle Calculator

Visit Right Triangle Calculator

Triangle Area Calculator

Visit Triangle Area Calculator

Circle Area Calculator

Visit Circle Area Calculator

Sphere Volume Calculator

Visit Sphere Volume Calculator

Cylinder Volume Calculator

Visit Cylinder Volume Calculator

Cone Volume Calculator

Visit Cone Volume Calculator

Hexagon Calculator

Visit Hexagon Calculator

Arc Length Calculator

Visit Arc Length Calculator

Law of Sines Calculator

Visit Law of Sines Calculator