Why Does the Law of Cosines Work for Any Triangle?

Introduction

The Law of Cosines works for any ordinary triangle because it combines side lengths with the angle between two sides to measure the third. Its formula is not limited to right triangles: it follows from basic distance geometry, with the cosine accounting for how much the two sides point in the same or opposite directions. The familiar Pythagorean theorem is one special case.

The Law of Cosines in Plain English

Imagine that you know the lengths of two sides of a triangle and the angle where those sides meet. The Law of Cosines lets you calculate the length of the third side. Using the conventional labels, side a is opposite angle A, side b is opposite angle B, and side c is opposite angle C. The formula is:

a2 = b2 + c2 − 2bc cos A

Here, “cos A” means the cosine of angle A. In a triangle, angle A is the angle between the sides of lengths b and c. The formula has matching versions for the other sides: b2 = a2 + c2 − 2ac cos B, and c2 = a2 + b2 − 2ab cos C.

The key idea is that the lengths of two sides alone do not determine the third. The angle between them matters too. If the sides open out more widely, the opposite side generally gets longer. If they point more nearly in the same direction, the opposite side gets shorter. The cosine term adjusts for this angle.

Where the Formula Comes From

A direct way to see why the law works is to place a triangle on a coordinate grid. Coordinates describe a point’s horizontal and vertical positions, making it possible to use the familiar distance formula: the distance between points is found from the differences in their coordinates.

Start at a vertex called A and place it at the origin, the point (0, 0). Put side AB of length c along the horizontal axis, so B is at (c, 0). Let side AC have length b, and let the angle between AB and AC be A. The coordinates of C are then (b cos A, b sin A). This describes a side of length b pointing at angle A from the horizontal.

The horizontal difference between B and C is c − b cos A. Their vertical difference is 0 − b sin A. The distance formula says that the square of the distance BC is the square of the horizontal difference plus the square of the vertical difference. Since BC is side a:

a2 = (c − b cos A)2 + (b sin A)2

Expanding the brackets gives c2 − 2bc cos A + b2 cos2 A + b2 sin2 A. The basic trigonometric identity sin2 A + cos2 A = 1 means the last two terms combine to b2. What remains is:

a2 = b2 + c2 − 2bc cos A

That is the Law of Cosines. This reasoning does not assume that the triangle is right-angled. It uses the distance between two points and applies to any angle A that can occur in a non-degenerate triangle.

How the Cosine Term Adjusts for the Angle

The term 2bc cos A is what makes the formula adapt to different triangle shapes. For an acute angle, which is less than 90 degrees, its cosine is positive. The formula therefore subtracts a positive amount from b2 + c2. The result is that a2 is smaller than it would be if the two sides met at a right angle.

At exactly 90 degrees, cos A equals zero. The adjustment disappears, leaving a2 = b2 + c2. This is the Pythagorean theorem. In other words, the Pythagorean theorem is not a separate rule that conflicts with the Law of Cosines; it is the right-angle case of the more general formula.

For an obtuse angle, which is greater than 90 degrees, the cosine is negative. The formula subtracts a negative quantity, which is equivalent to adding a positive one. So a2 becomes larger than b2 + c2. This matches the geometry: when the included angle opens past a right angle, the opposite side is longer than it would be at 90 degrees.

For example, angles of 60 degrees, 90 degrees, and 120 degrees have cosines of 0.5, 0, and −0.5, respectively. The same two side lengths therefore produce different third-side lengths depending on the included angle. The sign change is not a special exception; it is exactly how the formula represents an obtuse triangle.

Examples for Different Triangle Shapes

An acute triangle

Suppose two sides are 5 units and 7 units, and the angle between them is 60 degrees. The side opposite that angle is found by substituting b = 5, c = 7, and cos 60° = 0.5:

a2 = 52 + 72 − 2(5)(7)(0.5)
a2 = 25 + 49 − 35 = 39
a = √39, or about 6.24 units

The angle is acute, so the cosine term reduces the sum of the two squared side lengths. The answer is shorter than √74, the result that would apply if the included angle were a right angle.

An obtuse triangle

Now keep the same side lengths but use an included angle of 120 degrees. Since cos 120° = −0.5:

a2 = 52 + 72 − 2(5)(7)(−0.5)
a2 = 25 + 49 + 35 = 109
a = √109, or about 10.44 units

The third side is longer because the two known sides point away from each other at a wider angle. Both examples use the same two lengths; changing only the included angle changes the result.

Why “Any Triangle” Does Not Mean Any Numbers

The law applies to acute, right, and obtuse triangles, but the measurements still have to describe a real triangle. For example, with fixed side lengths, the angle must be compatible with the shape those sides can form. A zero-degree or 180-degree angle would flatten the points into a straight line, so it would not form an ordinary triangle.

The formula also respects the triangle inequality: the length of any one side must be less than the sum of the other two and greater than their difference. When the inputs describe a valid triangle, the Law of Cosines gives the corresponding third side. If inputs produce an impossible result, check that the angle is the one between the two supplied sides and that the measurements are consistent.

“Any triangle” also does not mean that the same numerical angle produces the same side for every pair of side lengths. The lengths b and c remain part of the calculation. The law works generally because it accounts for both the sizes of the sides and their relative direction.

Using the Law of Cosines Correctly

The formula is especially useful when you know two sides and their included angle. This information is often called side-angle-side data. It is also useful when all three sides are known and you want to find an angle. Rearranging the formula gives:

cos A = (b2 + c2 − a2) ÷ 2bc

Once the cosine value is found, an inverse cosine function on a calculator can give angle A. The result depends on the calculator’s angle setting, so make sure it is set to degrees if the problem uses degrees, or radians if it uses radians.

A frequent error is using an angle that is not between the two sides being squared and combined. In a2 = b2 + c2 − 2bc cos A, angle A must be between sides b and c. The side on the left, a, is opposite that angle. A small sketch with the labels placed opposite their matching angles can prevent mix-ups.

Another common mistake is dropping the minus sign. That sign matters especially for an obtuse angle, because its cosine is negative and the calculation then adds to the sum of the squared sides. It also helps to keep full calculator precision until the final step, rounding only the final side or angle to the requested level.

Why This Matters Beyond a Textbook

The Law of Cosines is a general tool for finding distances when two lengths and the angle between them are known. In geometry and trigonometry, it helps solve triangles that do not contain a right angle. The same underlying idea—resolving directions and calculating the distance between points—also appears in coordinate geometry and in practical settings where positions and directions are measured.

Its value is not that it replaces every other method. If a triangle is right-angled, the Pythagorean theorem may be quicker. If other side-angle information is known, another trigonometric method may be more convenient. The Law of Cosines is useful because it gives one consistent relationship that includes the right-triangle case and extends naturally to other triangle shapes.

Conclusion

The Law of Cosines works for any non-degenerate triangle because it is a form of the distance formula that includes the angle between two sides. The cosine measures how their directions affect the distance between their endpoints. At 90 degrees, the adjustment is zero and the Pythagorean theorem appears; for acute or obtuse angles, the same formula accounts for the change.