Law of Cosines Calculator
Calculate a missing side or angle in any triangle using the law of cosines. Enter values in degrees for angles.
What is the law of cosines?
The law of cosines is a triangle formula that connects the lengths of all three sides with one included angle. It is one of the most useful tools in trigonometry because it works for non-right triangles, where basic right-triangle formulas do not apply.
If you know two sides and the angle between them (SAS), you can find the third side. If you know all three sides (SSS), you can find any angle. That makes the law of cosines a core method for geometry, engineering, navigation, and physics problems.
Law of cosines formulas
For a triangle with sides a, b, c opposite angles A, B, C:
- c² = a² + b² - 2ab cos(C)
- a² = b² + c² - 2bc cos(A)
- b² = a² + c² - 2ac cos(B)
To solve for an angle, rearrange:
- C = arccos((a² + b² - c²) / (2ab))
- A = arccos((b² + c² - a²) / (2bc))
- B = arccos((a² + c² - b²) / (2ac))
How to use this calculator
Step-by-step
- Select the value you want to find from the dropdown.
- Enter the required known values (side lengths and/or angle in degrees).
- Click Calculate to get the result instantly.
- Use Reset to clear the fields and start a new triangle.
The calculator validates your inputs and checks triangle consistency where needed, so you can quickly catch impossible combinations.
Worked examples
Example 1: Find a side (SAS case)
Suppose a = 8, b = 11, and included angle C = 47°. Use:
c = √(a² + b² - 2ab cos C)
Substituting values gives c ≈ 8.13. This is exactly the kind of scenario where the law of cosines is best.
Example 2: Find an angle (SSS case)
If a = 7, b = 9, and c = 12, then:
C = arccos((a² + b² - c²) / (2ab))
Evaluating gives C ≈ 96.38°, meaning the triangle is obtuse at angle C.
Law of cosines vs. law of sines
Use the law of cosines when you have:
- Two sides and the included angle (SAS)
- All three sides (SSS)
Use the law of sines when you have:
- Two angles and one side (AAS or ASA)
- Two sides and a non-included angle (SSA, with caution)
Common input mistakes to avoid
- Entering an angle in radians instead of degrees.
- Using a negative or zero side length.
- Trying to form a triangle with side lengths that violate triangle inequality.
- Mixing up which angle is opposite which side.
Quick FAQ
Can this be used for right triangles?
Yes. In fact, if the included angle is 90°, the law of cosines reduces to the Pythagorean theorem.
Do I need all three sides to find an angle?
For this method, yes. Angle form of the law of cosines uses all three side lengths.
Why did I get an error?
Usually because of invalid inputs (like an angle not between 0 and 180 degrees, or impossible side combinations).
Final note
A reliable triangle side-and-angle finder saves time and prevents arithmetic mistakes. Use this law of cos calculator whenever you are solving oblique triangles in math homework, construction layouts, surveying, or engineering design.