Law of Cosines Calculator

Find missing sides or angles using c² = a² + b² − 2ab·cos(C). Use SAS (two sides and included angle) or SSS (three sides). Enter at least three values and leave one empty, then click Get result.

Sides
Angles (°)

SAS: two sides + included angle. SSS: three sides (leave one angle empty).

abcABC
Click Get result to solve for the missing value.

What is the Law of Cosines?

The Law of Cosines, also known as the Cosine Rule, is a fundamental theorem in trigonometry that relates the sides and angles of any triangle. It is a generalization of the Pythagorean theorem and works for all triangles—acute, right, and obtuse. The Law of Cosines states: c² = a² + b² - 2ab·cos(C), where a, b, and c are the lengths of the sides, and C is the angle opposite side c.

This powerful formula can be rearranged to solve for any side or angle. The three forms are: c² = a² + b² - 2ab·cos(C) for side c, a² = b² + c² - 2bc·cos(A) for side a, and b² = a² + c² - 2ac·cos(B) for side b. When solving for angles, we rearrange to: cos(C) = (a² + b² - c²) / (2ab), and similarly for angles A and B. The Law of Cosines is essential for solving triangles that cannot be solved with the Law of Sines, particularly when you have the included angle or all three sides.

How to use this Law of Cosines Calculator

Enter at least three known values from your triangle. The Law of Cosines works best with two specific cases: (1) SAS (Side-Angle-Side): Enter two sides and the included angle (the angle between those two sides), then leave the third side empty. (2) SSS (Side-Side-Side): Enter all three sides, then leave one angle empty. After entering your values, click the Get result button to calculate the missing side or angle.

For example, if you know side a = 5, side b = 7, and angle C = 60° (the angle between sides a and b), enter these values and leave side c empty. Click Get result to find side c. Alternatively, if you know all three sides (a = 5, b = 7, c = 8), enter them and leave one angle empty to find that angle. The calculator automatically determines which case applies and computes the result using the appropriate Law of Cosines formula. No sign-up required—use it instantly for homework, exams, or engineering problems.

Understanding the Law of Cosines Formula

The Law of Cosines formula c² = a² + b² - 2ab·cos(C) can be understood as an extension of the Pythagorean theorem. When angle C is 90°, cos(90°) = 0, and the formula reduces to c² = a² + b², which is the Pythagorean theorem. For angles less than 90° (acute), cos(C) is positive, so the term -2ab·cos(C) reduces the value of c². For angles greater than 90° (obtuse), cos(C) is negative, so -2ab·cos(C) becomes positive, increasing the value of c².

The geometric interpretation involves the projection of one side onto another. The term 2ab·cos(C) represents twice the product of the two sides and the cosine of the included angle, which accounts for how the angle affects the relationship between the sides. This makes the Law of Cosines particularly useful for solving triangles where the angle is between the two known sides, a situation where the Law of Sines cannot be directly applied.

When to Use the Law of Cosines

SAS Case (Side-Angle-Side): When you know two sides and the included angle (the angle between those two sides), use the Law of Cosines to find the third side. This is one of the most common applications. For example, if you know sides a and b and angle C (between them), you can find side c using: c² = a² + b² - 2ab·cos(C). This case always has a unique solution.

SSS Case (Side-Side-Side): When you know all three sides, use the Law of Cosines to find any angle. Rearrange the formula to solve for the cosine of the angle: cos(C) = (a² + b² - c²) / (2ab), then use the inverse cosine function to find the angle. This case also always has a unique solution, assuming the three sides can form a valid triangle (triangle inequality must be satisfied).

The Law of Cosines is not suitable for ASA (Angle-Side-Angle) or AAS (Angle-Angle-Side) cases—use the Law of Sines instead. Also, avoid using it for SSA (Side-Side-Angle) cases where the angle is not included, as the Law of Sines handles those better. The Law of Cosines is particularly powerful because it can solve any triangle given sufficient information, making it more versatile than the Law of Sines in many situations.

Law of Cosines vs Law of Sines

The Law of Cosines and Law of Sines are complementary tools for solving triangles, each with its strengths. Use the Law of Cosines when you have: SAS (two sides and included angle) or SSS (three sides). Use the Law of Sines when you have: ASA (two angles and included side), AAS (two angles and non-included side), or SSA (two sides and non-included angle, though this has the ambiguous case).

The Law of Cosines is more computationally intensive, involving square roots and inverse cosine functions, but it's more versatile and can solve any triangle. The Law of Sines is simpler algebraically but has limitations—it cannot solve SAS or SSS cases directly. Many triangle problems can be solved using both laws, but choosing the right one simplifies the solution process. Often, you'll use the Law of Cosines to find one side or angle, then use the Law of Sines to find the remaining values.

Applications of the Law of Cosines

Surveying and Navigation: The Law of Cosines is essential in surveying for calculating distances when you can measure two sides and the included angle. Navigators use it to determine positions and distances, especially in triangulation methods. GPS systems and mapping applications rely on similar trigonometric principles to calculate distances between points.

Engineering: Engineers use the Law of Cosines extensively in structural analysis, force calculations, and vector mathematics. In civil engineering, it helps calculate dimensions of triangular structures, trusses, and frameworks. Mechanical engineers use it for analyzing forces, moments, and stress distributions in triangular components.

Physics: In physics, the Law of Cosines appears in problems involving vector addition, especially when vectors are not perpendicular. It's used to calculate the magnitude of resultant vectors, analyze forces, and solve problems in mechanics, electromagnetism, and wave physics. The formula helps resolve forces into components and analyze systems with triangular relationships.

Computer Graphics: In computer graphics and game development, the Law of Cosines is used for calculating distances, angles, and transformations. It's essential for 3D rendering, collision detection, lighting calculations, and camera positioning. Graphics programmers use it extensively for spatial calculations and geometric transformations.

Architecture: Architects use the Law of Cosines when designing structures with triangular elements, calculating roof angles, determining beam lengths, and ensuring proper proportions. It's particularly useful for non-right-angled triangular structures and complex geometric designs.

Proof and Derivation

The Law of Cosines can be proven using coordinate geometry. Place one vertex at the origin and one side along the x-axis. Using the coordinates of the vertices and the distance formula, we can derive the Law of Cosines. Another elegant proof uses the Pythagorean theorem and trigonometric identities, showing how the Law of Cosines generalizes the Pythagorean theorem for non-right triangles.

The derivation involves dropping an altitude from one vertex to the opposite side, creating right triangles. Using the Pythagorean theorem on these right triangles and trigonometric relationships, we can derive the Law of Cosines formula. This geometric approach helps visualize why the formula works and provides insight into the relationship between sides and angles in any triangle.

Special Cases and Relationships

When angle C = 90°, the Law of Cosines reduces to the Pythagorean theorem: c² = a² + b², since cos(90°) = 0. This shows that the Pythagorean theorem is a special case of the Law of Cosines. For acute triangles (all angles < 90°), the cosine terms are positive, making the calculated side shorter than it would be in a right triangle. For obtuse triangles (one angle > 90°), the cosine of the obtuse angle is negative, making the calculated side longer.

The Law of Cosines also relates to the triangle's area. Using Heron's formula or the formula Area = (1/2)ab·sin(C), we can connect the Law of Cosines to area calculations. This relationship is useful in many applications where both side lengths and area are needed.

Summary

This Law of Cosines calculator solves triangles by finding missing sides or angles using the cosine rule: c² = a² + b² - 2ab·cos(C). Enter at least three known values, leave one unknown empty, then click Get result to calculate. The calculator handles SAS cases (two sides and included angle) and SSS cases (three sides). It's free, works instantly in your browser, and requires no sign-up. Use it for geometry homework, trigonometry problems, engineering calculations, surveying, navigation, physics problems, or any application requiring triangle solutions. Understanding the Law of Cosines is essential for success in mathematics, engineering, physics, and many practical fields. The Law of Cosines is a powerful tool that extends beyond right triangles, making it indispensable for solving real-world problems involving any type of triangle.