Law of Cosines : Formula, Proof, and Examples

#Trigonometry
TL;DR
The law of cosines states c2=a2+b2−2abcos⁡Cc^2 = a^2 + b^2 - 2ab\cos C, relating the three sides of any triangle to the cosine of one angle. This article covers when to use it (the SAS and SSS cases), its derivation, six worked examples, how it generalises the Pythagorean theorem, and the errors students make with obtuse angles.
BT
Bhanzu TeamLast updated on August 20, 202610 min read

The Rule That Fixes A Triangle You Can't Fully See

Give a navigator two sides and the angle between them, and the third side is fixed. No right angle is needed, no measuring tape reaches across the gap - the law of cosines turns two known distances and the angle between them into the exact length of the third. Surveyors, pilots, and GPS receivers all rely on it to close a triangle they can only partly measure.

The law of cosines does what the Pythagorean theorem cannot: it works for any triangle, not just right-angled ones. It relates all three sides to the cosine of one angle, which is why it sits at the centre of triangle-solving alongside the law of sines.

What Is The Law Of Cosines?

The law of cosines is an equation that holds for every triangle. For a triangle with sides aa, bb, cc and the angle ∠C\angle C opposite side cc:

c2=a2+b2−2abcos⁡Cc^2 = a^2 + b^2 - 2ab\cos C

By symmetry, the same relationship rotates around the triangle:

a2=b2+c2−2bccos⁡Aa^2 = b^2 + c^2 - 2bc\cos A

b2=a2+c2−2accos⁡Bb^2 = a^2 + c^2 - 2ac\cos B

In each version, the side on the left is opposite the angle on the right. The angle ∠C\angle C is the included angle - the one squeezed between the two sides aa and bb. The cosine here is the ordinary cosine ratio from the sin cos tan family, evaluated at the triangle's angle. Because the law works on every triangle, not only right-angled ones, it applies across all types of triangles - acute, right, and obtuse.

How Does It Extend The Pythagorean Theorem?

Set ∠C=90∘\angle C = 90^\circ. Then cos⁡90∘=0\cos 90^\circ = 0, and the correction term −2abcos⁡C-2ab\cos C vanishes:

c2=a2+b2−2ab(0)=a2+b2c^2 = a^2 + b^2 - 2ab(0) = a^2 + b^2

That is exactly the Pythagorean theorem for a right-angled triangle. So the law of cosines is the Pythagorean theorem with one extra term that measures how far the triangle bends away from a right angle. When ∠C\angle C is acute, cos⁡C>0\cos C > 0 and the term shrinks cc; when ∠C\angle C is obtuse, cos⁡C<0\cos C < 0 and the term grows cc.

How Do You Derive The Law Of Cosines?

The clearest derivation drops the triangle onto a coordinate grid. Place vertex CC at the origin, with side bb along the positive xx-axis, so vertex AA sits at (b,0)(b, 0). The angle ∠C\angle C opens from the xx-axis, so vertex BB has coordinates found from the cosine and sine of ∠C\angle C:

B=(acos⁡C,;asin⁡C)B = (a\cos C, ; a\sin C)

Side cc is the distance from A(b,0)A(b, 0) to B(acos⁡C,asin⁡C)B(a\cos C, a\sin C). Apply the distance formula:

c2=(acos⁡C−b)2+(asin⁡C−0)2c^2 = (a\cos C - b)^2 + (a\sin C - 0)^2

Expand each square, one line at a time:

c2=a2cos⁡2C−2abcos⁡C+b2+a2sin⁡2Cc^2 = a^2\cos^2 C - 2ab\cos C + b^2 + a^2\sin^2 C

Group the two a2a^2 terms and use the identity cos⁡2C+sin⁡2C=1\cos^2 C + \sin^2 C = 1:

c2=a2(cos⁡2C+sin⁡2C)+b2−2abcos⁡Cc^2 = a^2(\cos^2 C + \sin^2 C) + b^2 - 2ab\cos C

c2=a2+b2−2abcos⁡Cc^2 = a^2 + b^2 - 2ab\cos C

The coordinate placement is what makes the enclosed angle ∠C\angle C carry all the weight, and the Pythagorean identity is what collapses the sine and cosine terms into a clean result.

When Do You Use The Law Of Cosines?

The law of cosines solves two of the standard triangle cases. Knowing which case you are in is the whole skill.

  • SAS - two sides and the included angle. You know aa, bb, and ∠C\angle C, and you want the third side cc. Plug straight into c2=a2+b2−2abcos⁡Cc^2 = a^2 + b^2 - 2ab\cos C.

  • SSS - all three sides. You know aa, bb, cc and want an angle. Rearrange the formula: cos⁡C=a2+b2−c22ab\cos C = \dfrac{a^2 + b^2 - c^2}{2ab}, then take the inverse cosine.

If instead you know two angles and a side, or a side-side-angle pair, reach for the law of sines - that is its territory. A quick way to decide: if the known angle sits between the two known sides, the law of cosines is the tool.

Examples Of The Law Of Cosines

Example 1

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

c2=a2+b2−2abcos⁡C=25+49−2(5)(7)cos⁡60∘c^2 = a^2 + b^2 - 2ab\cos C = 25 + 49 - 2(5)(7)\cos 60^\circ

c2=74−70(0.5)=74−35=39c^2 = 74 - 70(0.5) = 74 - 35 = 39

c=39≈6.24c = \sqrt{39} \approx 6.24

Final answer: c=39≈6.24c = \sqrt{39} \approx 6.24.

Example 2

A triangle has a=6a = 6, b=10b = 10, and included angle ∠C=120∘\angle C = 120^\circ. Find side cc. First instinct, then the correct route.

The common slip is to read cos⁡120∘\cos 120^\circ as +0.5+0.5, forgetting the quadrant sign:

c2=36+100−2(6)(10)(0.5)=136−60=76,c≈8.72c^2 = 36 + 100 - 2(6)(10)(0.5) = 136 - 60 = 76, \quad c \approx 8.72

Check that against the triangle. The angle ∠C=120∘\angle C = 120^\circ is obtuse, so side cc, opposite the largest angle, must be the longest side, longer than b=10b = 10. An answer of 8.728.72 is shorter than 1010, which is impossible.

The fix is the sign. In the second quadrant cos⁡120∘=−0.5\cos 120^\circ = -0.5:

c2=136−2(6)(10)(−0.5)=136+60=196c^2 = 136 - 2(6)(10)(-0.5) = 136 + 60 = 196

c=196=14c = \sqrt{196} = 14

Now c=14>10c = 14 > 10, exactly as an obtuse triangle demands.

Final answer: c=14c = 14.

Example 3

A triangle has sides 44, 55, 66. Find its largest angle.

The largest angle sits opposite the longest side, 66. Solve for ∠C\angle C with c=6c = 6, a=4a = 4, b=5b = 5:

cos⁡C=a2+b2−c22ab=16+25−362(4)(5)=540=0.125\cos C = \frac{a^2 + b^2 - c^2}{2ab} = \frac{16 + 25 - 36}{2(4)(5)} = \frac{5}{40} = 0.125

C=cos⁡−1(0.125)≈82.8∘C = \cos^{-1}(0.125) \approx 82.8^\circ

Final answer: the largest angle is about 82.8∘82.8^\circ, which is acute, not the right angle a quick guess might assume.

Example 4

Confirm the Pythagorean reduction: a triangle with a=3a = 3, b=4b = 4, ∠C=90∘\angle C = 90^\circ.

c2=9+16−2(3)(4)cos⁡90∘=25−24(0)=25c^2 = 9 + 16 - 2(3)(4)\cos 90^\circ = 25 - 24(0) = 25

c=5c = 5

Final answer: c=5c = 5, the familiar 3-4-5 right triangle, recovered from the law of cosines.

Example 5

Two straight roads leave a junction at an angle of 100∘100^\circ. A car drives 1212 km down one and 99 km down the other. How far apart are the endpoints?

d2=122+92−2(12)(9)cos⁡100∘=144+81−216(−0.1736)d^2 = 12^2 + 9^2 - 2(12)(9)\cos 100^\circ = 144 + 81 - 216(-0.1736)

d2=225+37.5=262.5,d≈16.2 kmd^2 = 225 + 37.5 = 262.5, \quad d \approx 16.2 \text{ km}

Final answer: the endpoints are about 16.216.2 km apart.

Example 6

A triangle has sides 77, 88, 99. Find the angle opposite the side of length 99.

cos⁡C=72+82−922(7)(8)=49+64−81112=32112≈0.2857\cos C = \frac{7^2 + 8^2 - 9^2}{2(7)(8)} = \frac{49 + 64 - 81}{112} = \frac{32}{112} \approx 0.2857

C=cos⁡−1(0.2857)≈73.4∘C = \cos^{-1}(0.2857) \approx 73.4^\circ

Final answer: the angle is about 73.4∘73.4^\circ.

Where Does The Law Of Cosines Earn Its Keep? - "Closing a triangle nobody can walk across"

The law of cosines exists to measure a distance you cannot reach with a ruler. Give it two sides and the angle between them, and it hands back the third side exactly.

  • Navigation and dead reckoning. A ship that sails one leg, turns through a known angle, and sails another can compute its straight-line distance from the start without any landmark - pure triangle-solving.

  • Surveying and GPS. Land surveyors and satellite receivers fix a point by relating measured distances and angles; the law of cosines converts those raw measurements into positions.

  • Engineering and structures. Truss members meeting at non-right angles have lengths and joint angles bound by the law of cosines, so a designer can size a diagonal from the two members it connects.

Why does the correction term carry a minus sign? Because a wider enclosed angle pushes the far vertex apart, and the cosine - positive for acute angles, negative for obtuse - measures exactly that spread. The formula and the geometry are the same statement, which is documented in full at Wolfram MathWorld.

The Mathematicians Behind The Law Of Cosines

Euclid (c. 300 BC, Alexandria) proved the geometric ancestor of the law in Elements Propositions II.12 and II.13, stating the acute and obtuse cases as area relationships without trigonometry. Jamshīd al-Kāshī (c. 1380–1429, Persia) recast those results into the numerical, cosine-based form used today, which is why the rule is called Al-Kashi's theorem in France; his biography sits at MacTutor.

Common Mistakes With The Law Of Cosines

Mistake 1: Dropping The Sign On An Obtuse Angle

Where it slips in: Any SAS problem where the included angle is more than 90∘90^\circ.

Don't do this: Using cos⁡120∘=+0.5\cos 120^\circ = +0.5. In the second quadrant, cosine is negative.

The correct way: cos⁡120∘=−0.5\cos 120^\circ = -0.5, which flips the correction term from subtracting to adding and lengthens the opposite side. The check that saves you: the side opposite an obtuse angle is always the longest, so an answer shorter than its neighbours signals a sign error. The rusher who plugs in the reference-angle cosine without checking the quadrant lands here most often.

Mistake 2: Pairing The Wrong Side With The Angle

Where it slips in: Setting up the formula when the labels aa, bb, cc are not the ones in the diagram.

Don't do this: Writing c2=a2+b2−2abcos⁡Ac^2 = a^2 + b^2 - 2ab\cos A, using the angle that is not opposite side cc.

The correct way: The side on the left must be opposite the angle on the right. Match cc with ∠C\angle C, aa with ∠A\angle A, bb with ∠B\angle B every time. The memorizer who recites one version of the formula but never re-labels the triangle produces a right-looking equation that solves the wrong triangle.

Mistake 3: Adding Instead Of Subtracting The Correction Term

Where it slips in: Rushing the arithmetic of −2abcos⁡C-2ab\cos C.

Don't do this: Computing a2+b2+2abcos⁡Ca^2 + b^2 + 2ab\cos C for an acute angle.

The correct way: The term is subtracted: −2abcos⁡C-2ab\cos C. A sign error here is the trigonometric cousin of a dead-reckoning slip - the same class of arithmetic mistake that has put ships and aircraft off their plotted course, where a wrong intermediate value quietly compounds into a real position error. Keep the minus sign attached and evaluate the cosine last.

Key Takeaways

  • The law of cosines is c2=a2+b2−2abcos⁡Cc^2 = a^2 + b^2 - 2ab\cos C, valid for every triangle.

  • Use it for SAS (find the third side) and SSS (find an angle).

  • It generalises the Pythagorean theorem: at ∠C=90∘\angle C = 90^\circ the cosine term disappears.

  • For an obtuse included angle the cosine is negative, which lengthens the opposite side.

  • Match each side to the angle opposite it, and keep the minus sign on the 2abcos⁡C2ab\cos C term.

To work through the law of cosines with a teacher, explore Bhanzu's trigonometry tutor sessions, a high school math tutor for triangle-solving practice, or live math classes online with peers from 20+ countries.

A Practical Next Step

Practice these to solidify your understanding: solve a triangle with a=8a = 8, b=6b = 6, ∠C=110∘\angle C = 110^\circ for side cc, then use the SSS rearrangement to recover ∠C\angle C from your three sides. If the obtuse sign trips you up, come back to the properties section above. Want a live Bhanzu trainer to solve triangles with you? Book a free demo class.

Read More

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is the law of cosines formula?
c2=a2+b2−2abcos⁡Cc^2 = a^2 + b^2 - 2ab\cos C, with cc the side opposite angle ∠C\angle C. The formula rotates for the other sides and angles.
When should I use the law of cosines instead of the law of sines?
Use the law of cosines for SAS (two sides and the included angle) or SSS (three sides). Use the law of sines when you know two angles and a side, or a side-side-angle pair.
Does the law of cosines work for right triangles?
Yes. When the angle is 90∘90^\circ, cos⁡90∘=0\cos 90^\circ = 0 and the formula reduces to the Pythagorean theorem c2=a2+b2c^2 = a^2 + b^2.
How do I find an angle with the law of cosines?
Rearrange to cos⁡C=a2+b2−c22ab\cos C = \dfrac{a^2 + b^2 - c^2}{2ab}, then take the inverse cosine. This is the SSS case.
Who discovered the law of cosines?
Its geometric form goes back to Euclid; the modern cosine-based statement was developed by the Persian mathematician Al-Kāshī in the 15th century.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →