Law of Cosines Calculator

Solve a triangle using the law of cosines — find a missing side from two sides and the included angle, or find an angle from three sides.

Share this calculator

How to use

Enter two sides (a and b) and the included angle C to find side c and solve the full triangle.

Enter values to solve Provide sides a, b and the included angle C to find side c using the Law of Cosines.

Also in Triangles

Trigonometry

Law of cosines: find missing sides and angles in any triangle

The law of cosines calculator solves a triangle when you know three sides (SSS) or two sides and the included angle (SAS). It generalises the Pythagorean theorem to non-right triangles and returns all missing sides, angles, and the area.

The law of cosines formula

The law of cosines relates the three sides of any triangle to one of its angles. It is most useful when you have two sides and the angle between them (SAS) or all three sides (SSS). For a right triangle the formula reduces to the Pythagorean theorem because cos(90) is zero.

c^2 = a^2 + b^2 - 2ab * cos(C)

Finds side c from sides a, b and included angle C.

cos(C) = (a^2 + b^2 - c^2) / (2ab)

Finds angle C from all three sides.

When to use the law of cosines

Use SAS mode when you know two sides and the angle between them. Use SSS mode when you know all three sides and need the angles. For other configurations such as ASA or AAS, the law of sines is usually more convenient.

Relationship to the Pythagorean theorem

When angle C is exactly 90 degrees, cos(C) equals zero, so the formula simplifies to c squared equals a squared plus b squared. The law of cosines is therefore a generalisation that works for all triangles, not just right triangles.

Frequently asked questions

Can the law of cosines find any angle from three sides?

Yes. Rearrange the formula to solve for each angle in turn: cos(A) = (b^2 + c^2 - a^2) / (2bc), and similarly for B and C.

What happens if the angle is 90 degrees?

cos(90) = 0, so the cross term vanishes and the formula becomes the Pythagorean theorem.

Is the law of cosines the same as the cosine rule?

Yes. "Law of cosines" and "cosine rule" are two names for the same formula.

Related

More from nearby categories

These related calculators come from the same leaf category, nearby sibling categories, or the same top-level topic.