Applying the law of cosines comes down to four moves: match the angle to its opposite side, pick the right form of the equation, substitute carefully (watching units and calculator mode), and check that the answer is reasonable. The law works on triangles that are not right when you know either two sides with the included angle or all three sides. For sides aa, bb, cc opposite angles AA, BB, CC,

c2=a2+b22abcosC,c^2 = a^2 + b^2 - 2ab\cos C,

where side cc is opposite angle CC, and CC is the angle between sides aa and bb. The same pattern rotates:

a2=b2+c22bccosA,b2=a2+c22accosB.a^2 = b^2 + c^2 - 2bc\cos A, \qquad b^2 = a^2 + c^2 - 2ac\cos B.

If C=90C = 90^\circ then cosC=0\cos C = 0 and the formula collapses to c2=a2+b2c^2 = a^2 + b^2, so the law of cosines generalizes the Pythagorean theorem.

When to use the law of cosines

The most common setup is SAS: two sides and the included angle (the angle formed by the two known sides). It also handles SSS: all three sides known, solving for an angle — there you rearrange before using inverse cosine. If instead you know a side and its opposite angle, the law of sines is usually the better first tool. The law of cosines is the standard choice in geometry, trigonometry, surveying, navigation, and any non-right-triangle distance problem.

What the formula is doing

With two sides fixed, the third depends on the angle between them. A larger included angle makes the opposite side longer; a smaller one makes it shorter. The term 2abcosC-2ab\cos C corrects the bare sum a2+b2a^2 + b^2 for that angle — and that correction is the part worth remembering. Drop it and you are treating every triangle as a right triangle.

The procedure, step by step

  1. Match angle and opposite side. Pick the angle you know or want, then label the side across from it.
  2. Choose the right form. Use c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C when cc is opposite CC, or the matching version for aa or bb.
  3. Substitute with units and angle mode. Insert the known values and set the calculator to degrees or radians to match the problem.
  4. Solve and check reasonableness. The unknown side must fit the triangle, and a right-angle case should reduce to Pythagoras.

A full run-through: find a side

A triangle has a=5a = 5, b=7b = 7, and included angle C=60C = 60^\circ. Find cc.

Step 1: cc is opposite CC. Step 2: use c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C. Step 3, substitute:

c2=52+722(5)(7)cos60.c^2 = 5^2 + 7^2 - 2(5)(7)\cos 60^\circ.

Since cos60=12\cos 60^\circ = \tfrac{1}{2},

c2=25+4970(12)=7435=39,c^2 = 25 + 49 - 70\left(\tfrac{1}{2}\right) = 74 - 35 = 39,

so c=396.24c = \sqrt{39} \approx 6.24. Step 4: that fits — the third side is longer than 55 but shorter than 7+5=127 + 5 = 12, consistent with a moderate angle.

Finding an angle from three sides

With all three sides known, isolate the cosine first:

cosC=a2+b2c22ab,C=cos1 ⁣(a2+b2c22ab).\cos C = \frac{a^2 + b^2 - c^2}{2ab}, \qquad C = \cos^{-1}\!\left(\frac{a^2 + b^2 - c^2}{2ab}\right).

This makes sense only when aa, bb, cc form a valid triangle. If the value inside cos1\cos^{-1} leaves [1,1][-1, 1], there is an earlier algebra or data error.

Why the formula holds

A clean proof uses coordinates. Place one vertex at (0,0)(0, 0), another at (b,0)(b, 0), and the third at (acosC,asinC)(a\cos C, a\sin C), since that point is distance aa from the origin at angle CC. The distance formula gives

c2=(bacosC)2+(0asinC)2,c^2 = (b - a\cos C)^2 + (0 - a\sin C)^2,

which expands to

c2=b22abcosC+a2cos2C+a2sin2C.c^2 = b^2 - 2ab\cos C + a^2\cos^2 C + a^2\sin^2 C.

Apply sin2C+cos2C=1\sin^2 C + \cos^2 C = 1 and the last two terms combine into a2a^2, leaving

c2=a2+b22abcosC.c^2 = a^2 + b^2 - 2ab\cos C.

Where each step trips people up

  • At "match angle and opposite side," pairing the wrong ones. If you use angle CC, the left side must be c2c^2.
  • At "choose the right form," dropping the correction. When the angle is not 9090^\circ, you cannot discard 2abcosC-2ab\cos C.
  • At "substitute," wrong calculator mode. Degrees in the problem means degree mode; radians means radian mode.
  • At the SSS route, sloppy algebra. Isolate cosine cleanly before inverse cosine; a small slip there throws the angle off badly. Self-check: in school math the two main jobs are a missing side from SAS and a missing angle from SSS. A right triangle is usually simpler with Pythagoras; a side-pair with a known angle may suit the law of sines.

FAQ

Run the steps on a=8a = 8, b=11b = 11, C=30C = 30^\circ to find cc, then change CC to 120120^\circ and compare. Watching the opposite side grow with the angle is one of the fastest ways to make the formula intuitive. For step-by-step feedback on your own numbers, explore a similar triangle in GPAI Solver.

Frequently Asked Questions

What is the law of cosines in simple terms?
The law of cosines relates the three sides of any triangle to one of its angles. It is especially useful when the triangle is not a right triangle.
When should you use the law of cosines?
Use it when you know two sides and the included angle, or when you know all three sides and want to find an angle.

Need help with a problem?

Upload your question and get a verified, step-by-step solution in seconds.

Open GPAI Solver →