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.