Enter Known Values
Enter either 3 sides (SSS) or 2 sides with the included angle (SAS).
Results
Reference Guide
Example: SSS case (a=7, b=5, c=8)
Enter any known values above to calculate the rest
Triangle Visualization
Understanding the Law of Cosines
The Law of Cosines is a fundamental theorem in trigonometry that generalizes the Pythagorean theorem to work with any triangle, not just right triangles. It provides a way to find missing sides or angles when you have specific combinations of triangle measurements, making it one of the most versatile tools in triangle solving.
The Law of Cosines Formula
For any triangle with sides a, b, c and opposite angles A, B, C, the Law of Cosines states:
c² = a² + b² - 2ab·cos(C)
b² = a² + c² - 2ac·cos(B)
a² = b² + c² - 2bc·cos(A)
Notice how these formulas resemble the Pythagorean theorem (a² + b² = c²) with an additional term: -2ab·cos(C). When the angle C = 90°, cos(90°) = 0, and the formula reduces exactly to the Pythagorean theorem. This shows that the Law of Cosines is a generalization that works for all triangles.
When to Use the Law of Cosines
The Law of Cosines is specifically designed for two triangle configurations:
1. SSS (Side-Side-Side)
When you know all three sides and want to find the angles. Rearrange the formula to solve for the angle:
cos(C) = (a² + b² - c²) / (2ab)
C = arccos((a² + b² - c²) / (2ab))
Repeat this process for the other two angles. This is the only straightforward method to find angles when you only know the three sides.
2. SAS (Side-Angle-Side)
When you know two sides and the angle between them (the included angle). Use the formula directly to find the third side:
c = √(a² + b² - 2ab·cos(C))
Once you have all three sides, you can find the remaining angles using the Law of Cosines or switch to the Law of Sines.
Why the Law of Cosines Works
The Law of Cosines emerges from applying the distance formula to triangles placed on a coordinate system. When you position one vertex at the origin and another along the positive x-axis, the third vertex's coordinates involve trigonometric functions. Using the distance formula between these points and algebraic manipulation yields the Law of Cosines. This geometric derivation reveals why the formula contains both the sides and the cosine of the angle - it's encoding the geometric relationship between the triangle's vertices in space.
Law of Cosines vs Law of Sines
Both laws are powerful, but they apply to different situations:
- Law of Cosines: Use for SSS (three sides) or SAS (two sides with included angle)
- Law of Sines: Use for ASA, AAS (angle combinations) or SSA (ambiguous case)
- Key difference: Law of Cosines can work with sides alone; Law of Sines requires at least one angle-side pair
- When both work: Law of Sines is usually simpler computationally, but Law of Cosines avoids the ambiguous SSA case
Special Cases and Observations
- Right triangles: When C = 90°, cos(C) = 0, reducing to a² + b² = c² (Pythagorean theorem)
- Acute triangles: All angles less than 90° mean all cosine terms are positive
- Obtuse triangles: One angle greater than 90° makes one cosine term negative, which increases the squared side value
- Numerical stability: Always calculate the largest angle first (opposite the longest side) to avoid numerical errors
Real-World Applications
The Law of Cosines is essential in many fields:
- Navigation and GPS: Calculating distances between points when angles from reference points are known
- Engineering: Analyzing forces in non-right triangular frameworks and trusses
- Astronomy: Computing distances to stars and planets using angular measurements
- Robotics: Determining joint angles and arm positions in inverse kinematics
- Game Development: Collision detection and trajectory calculations for non-orthogonal movements
- Surveying: Measuring land parcels and inaccessible distances
Using This Calculator
Our Law of Cosines Calculator handles both SSS and SAS cases:
- For SSS: Enter all three sides (a, b, c). The calculator will find all three angles.
- For SAS: Enter two sides and the angle BETWEEN them (e.g., sides a and b with angle C). The calculator will find the third side and remaining angles.
- Click "Calculate" to see complete results including area and perimeter
- Review the visual diagram to verify the triangle geometry
The calculator automatically validates triangle inequality for SSS and provides clear error messages if the inputs cannot form a valid triangle. All calculations use high-precision mathematics for accurate results.
Frequently Asked Questions
What is the Law of Cosines formula?
The Law of Cosines states that for any triangle, c² = a² + b² - 2ab·cos(C), where c is a side and C is the opposite angle. This formula can be rearranged for any side-angle pair. It generalizes the Pythagorean theorem to work with all triangles, not just right triangles.
When should I use the Law of Cosines instead of the Law of Sines?
Use the Law of Cosines for SSS (when you know all three sides) or SAS (when you know two sides and the included angle between them). The Law of Sines cannot handle these cases effectively. For ASA, AAS, and SSA cases, the Law of Sines is usually more straightforward.
How is the Law of Cosines related to the Pythagorean theorem?
The Law of Cosines is a generalization of the Pythagorean theorem. In a right triangle where C = 90°, cos(90°) = 0, so the term -2ab·cos(C) becomes zero, leaving c² = a² + b², which is exactly the Pythagorean theorem. This shows that the Pythagorean theorem is a special case of the Law of Cosines.
Can the Law of Cosines find angles from three sides?
Yes! This is one of its most powerful uses. Rearrange the formula to cos(C) = (a² + b² - c²) / (2ab), then find C = arccos((a² + b² - c²) / (2ab)). This is the only practical way to find angles when you only know the three side lengths. Repeat for the other angles.
What does SAS mean and why must the angle be "included"?
SAS means Side-Angle-Side, where you know two sides and the angle BETWEEN them (the included angle). For example, sides a and b with angle C, or sides b and c with angle A. The angle must be included (between the two known sides) because that's what the Law of Cosines formula requires. If you know two sides and a non-included angle, you have SSA, which requires the Law of Sines instead.
Why might I get an error calculating with the Law of Cosines?
The most common error is violating the triangle inequality theorem - the sum of any two sides must be greater than the third side. Another error occurs if the value inside arccos is outside the range [-1, 1], which happens with invalid measurements. Our calculator automatically validates your inputs and provides clear error messages if the values cannot form a valid triangle.
Additional Resources
-
Khan Academy - Law of Cosines
Video lessons on the Law of Cosines with step-by-step examples
-
Math is Fun - Solving SSS Triangles
Interactive guide to using the Law of Cosines for SSS cases