Law of Cosines
The law of cosines connects all three sides of a triangle with one angle: c^2 = a^2 + b^2 - 2ab \cos C. Use it to find the third side when you know two sides and the angle between them (SAS), or to find an angle when you know all three sides (SSS). It works for every triangle.
Before this lesson: You should know the Pythagorean Theorem, the Law of Sines and Inverse Trig Functions.
What the Law of Cosines Means
The law of sines needs a side and the angle across from it. With SAS or SSS, you don’t have that pair, so the law of sines can’t start. The law of cosines fills the gap.
Think of it as the Pythagorean theorem with a correction term. When C = 90^\circ, \cos C = 0, so the formula becomes c^2 = a^2 + b^2. When C is bigger than 90^\circ, the correction makes c longer. When C is smaller, it makes c shorter.
The Law of Cosines Formula
c^2 = a^2 + b^2 - 2ab \cos C
The same pattern works for any side. Put the side you want on the left, and use the angle across from it:
- a^2 = b^2 + c^2 - 2bc \cos A
- b^2 = a^2 + c^2 - 2ac \cos B
To find an angle from three sides, solve for the cosine:
\cos C = \frac{a^2 + b^2 - c^2}{2ab}When to use it
- SAS: two sides and the angle between them. Find the third side.
- SSS: all three sides. Find an angle, starting with the largest one, across from the longest side.
After you find one angle, you can switch to the law of sines for the rest. Find the largest angle first, because the inverse sine can’t tell an obtuse angle from an acute one, but the inverse cosine can.
Worked Examples
Use a calculator in degree mode. Round sides to the nearest hundredth and angles to the nearest tenth of a degree.
Example 1: Find the third side (SAS)
In triangle ABC, a = 8, b = 11 and C = 37^\circ. Find c.
c^2 = a^2 + b^2 - 2ab \cos C
Write the formula.
c^2 = 8^2 + 11^2 - 2(8)(11) \cos 37^\circ
Substitute.
c^2 = 64 + 121 - 2(8)(11) \cos 37^\circ
Square the sides.
c^2 = 185 - 176 \cos 37^\circ
Multiply 2(8)(11).
c^2 \approx 185 - 176(0.7986)
Find the cosine.
c^2 \approx 185 - 140.56
Multiply.
c^2 \approx 44.44
Subtract.
c \approx \sqrt{44.44} \approx 6.67Take the square root (see square roots)
Answer: c \approx 6.67
Example 2: Find an angle (SSS)
A triangle has sides a = 7, b = 9 and c = 12. Find the largest angle.
The longest side is c = 12, so the largest angle is C
\cos C = \frac{a^2 + b^2 - c^2}{2ab}Use the angle form.
\cos C = \frac{49 + 81 - 144}{2(7)(9)}Substitute.
\cos C = \frac{-14}{126}Simplify the top.
\cos C \approx -0.1111
Divide.
C \approx \cos^{-1}(-0.1111) \approx 96.4^\circUse the inverse cosine.
Answer: C \approx 96.4^\circ. The cosine is negative, so the angle is obtuse.
Example 3: Solve a whole triangle (SSS)
Solve the triangle with a = 5, b = 6 and c = 7.
\cos C = \frac{25 + 36 - 49}{2(5)(6)} = \frac{12}{60} = 0.2Find the largest angle C first.
C = \cos^{-1}(0.2) \approx 78.5^\circUse the inverse cosine.
\sin A = \frac{5 \sin 78.5^\circ}{7} \approx \frac{5(0.9799)}{7} \approx 0.6999Switch to the law of sines for A.
A \approx \sin^{-1}(0.6999) \approx 44.4^\circUse the inverse sine.
B = 180^\circ - 78.5^\circ - 44.4^\circ = 57.1^\circ
Use the angle sum for B.
Answer: A \approx 44.4^\circ, B \approx 57.1^\circ, C \approx 78.5^\circ. Check: the longest side c is across from the largest angle C.
Example 4: Word problem with two ships
Two ships leave a port at the same time. One sails at 20 km/h and the other at 25 km/h. Their paths make a 65^\circ angle. How far apart are they after 2 hours?
Find each distance: 20 \cdot 2 = 40 km and 25 \cdot 2 = 50 km
d^2 = 40^2 + 50^2 - 2(40)(50) \cos 65^\circ
The 65^\circ angle is between these sides, so this is SAS.
d^2 = 1600 + 2500 - 4000 \cos 65^\circ
Square the sides.
d^2 \approx 4100 - 4000(0.4226) = 4100 - 1690.4
Find the cosine and multiply.
d^2 \approx 2409.6
Subtract.
d \approx 49.09
Take the square root.
Answer: The ships are about 49.09 km apart.
Example 5: Word problem with a turn
A hiker walks 3.2 km east. Then she turns 40^\circ to her left and walks 2.5 km. How far is she from where she started?
Find the angle inside the triangle. Turning 40^\circ off a straight line leaves an inside angle of 180^\circ - 40^\circ = 140^\circ
d^2 = 3.2^2 + 2.5^2 - 2(3.2)(2.5) \cos 140^\circ
Set up SAS.
d^2 = 10.24 + 6.25 - 16 \cos 140^\circ
Square the sides and multiply.
\cos 140^\circ \approx -0.7660
Find the cosine.
-16(-0.7660) = 12.256
Multiply.
d^2 \approx 10.24 + 6.25 + 12.256 = 28.746
Add (see adding and subtracting integers)
d \approx 5.36
Take the square root.
Answer: She is about 5.36 km from her start. The inside angle is obtuse, so the cosine is negative and the distance is more than \sqrt{3.2^2 + 2.5^2} \approx 4.06.
Common Mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Using the wrong angle | Using angle A to find side c | The angle in the formula is across from the side you are finding. |
| Subtracting before multiplying | 185 - 176 \cos 37^\circ = 9 \cos 37^\circ | Follow the order of operations: multiply 176 \cos 37^\circ first. |
| Forgetting the square root | Giving c \approx 44.44 | That is c^2. Take the square root at the end. |
| Sign error with an obtuse angle | Using \cos 140^\circ \approx 0.7660 | Cosine is negative for angles between 90^\circ and 180^\circ. |
| Finding a small angle first in SSS | Using the law of sines for the largest angle | Find the largest angle with the law of cosines first. |
Related Methods
Check a triangle’s type
Compare c^2 with a^2 + b^2, where c is the longest side. If c^2 is less, the triangle is acute. If equal, it is right. If more, it is obtuse. This matches the converse of the Pythagorean theorem.
Why it works
Put C at the origin with side b on the x-axis, so A = (b, 0) and B = (a \cos C, a \sin C). The distance formula gives c^2 = (a \cos C - b)^2 + (a \sin C)^2. Expand and use \sin^2 C + \cos^2 C = 1 to get c^2 = a^2 + b^2 - 2ab \cos C.
Law of sines or law of cosines?
If you know a side and the angle across from it, use the law of sines. If you know SAS or SSS, start with the law of cosines.
Practice Problems
Round sides to the nearest hundredth and angles to the nearest tenth of a degree.
- In triangle ABC, a = 5, b = 7 and C = 60^\circ. Find the exact value of c.
- In triangle ABC, b = 10, c = 14 and A = 110^\circ. Find a.
- A triangle has sides 4, 5 and 6. Find its largest angle.
- A triangle has sides 3, 5 and 7. Find the exact measure of its largest angle.
- Solve the triangle with a = 9, b = 10 and c = 13.
- Is a triangle with sides 6, 8 and 11 acute, right or obtuse?
- In triangle ABC, a = 2, b = 3 and C = 120^\circ. Find the exact value of c.
- A parallelogram has sides 6 and 10 with a 50^\circ angle between them. Find the shorter diagonal.
- Two planes leave an airport. One flies 120 miles and the other flies 150 miles. The angle between their paths is 35^\circ. How far apart are they?
- A triangular garden has sides 18 ft, 24 ft and 32 ft. Find the angle between the 18 ft and 24 ft sides.
Show answers
1.
c^2 = 5^2 + 7^2 - 2(5)(7) \cos 60^\circ
Substitute.
c^2 = 25 + 49 - 70 \cos 60^\circ
Square and multiply.
c^2 = 74 - 35 = 39
Use \cos 60^\circ = \frac{1}{2}.
c = \sqrt{39}Take the square root.
Answer: c = \sqrt{39} \approx 6.24
2.
a^2 = 10^2 + 14^2 - 2(10)(14) \cos 110^\circ
Substitute.
a^2 = 100 + 196 - 280 \cos 110^\circ
Square and multiply.
\cos 110^\circ \approx -0.3420
Find the cosine.
-280(-0.3420) \approx 95.77
Multiply.
a^2 \approx 296 + 95.77 = 391.77
Add.
a \approx 19.79
Take the square root.
Answer: a \approx 19.79
3.
\cos C = \frac{4^2 + 5^2 - 6^2}{2(4)(5)}The largest angle is across from 6.
\cos C = \frac{16 + 25 - 36}{40} = \frac{5}{40} = 0.125Simplify.
C = \cos^{-1}(0.125) \approx 82.8^\circTake the inverse cosine.
Answer: about 82.8^\circ
4.
\cos C = \frac{3^2 + 5^2 - 7^2}{2(3)(5)}The largest angle is across from 7.
\cos C = \frac{9 + 25 - 49}{30} = \frac{-15}{30} = -\frac{1}{2}Simplify.
Cosine is -\frac{1}{2} at 120^\circ
Answer: C = 120^\circ
5.
\cos C = \frac{81 + 100 - 169}{2(9)(10)} = \frac{12}{180} \approx 0.0667Find the largest angle first with the law of cosines.
C \approx 86.2^\circ
Take the inverse cosine.
\cos A = \frac{b^2 + c^2 - a^2}{2bc} = \frac{100 + 169 - 81}{2(10)(13)} = \frac{188}{260} \approx 0.7231Find angle A with the law of cosines.
A \approx 43.7^\circ
Take the inverse cosine.
B = 180^\circ - 86.2^\circ - 43.7^\circ = 50.1^\circ
Use the angle sum to find the third angle.
Answer: A \approx 43.7^\circ, B \approx 50.1^\circ, C \approx 86.2^\circ
6.
11^2 = 121
Longest side squared.
6^2 + 8^2 = 36 + 64 = 100
Sum of the other squares.
121 \gt 100
Compare.
\cos C \lt 0
The longest side squared is bigger, so the cosine is negative.
Answer: obtuse
7.
c^2 = 2^2 + 3^2 - 2(2)(3) \cos 120^\circ
Substitute.
c^2 = 4 + 9 - 12 \cos 120^\circ
Square and multiply.
c^2 = 13 - 12(-\frac{1}{2}) = 13 + 6 = 19Use \cos 120^\circ = -\frac{1}{2}.
c = \sqrt{19}Take the square root.
Answer: c = \sqrt{19} \approx 4.36
8.
d^2 = 6^2 + 10^2 - 2(6)(10) \cos 50^\circ
The shorter diagonal is across from the 50^\circ angle.
d^2 = 36 + 100 - 120 \cos 50^\circ
Square and multiply.
d^2 \approx 136 - 120(0.6428) \approx 136 - 77.13
Find the cosine and multiply.
d^2 \approx 58.87
Subtract.
d \approx 7.67
Take the square root.
Answer: about 7.67
9.
d^2 = 120^2 + 150^2 - 2(120)(150) \cos 35^\circ
Two sides and the included angle are known (SAS), so use the law of cosines.
d^2 = 14400 + 22500 - 36000 \cos 35^\circ
Square and multiply.
d^2 \approx 36900 - 36000(0.8192) \approx 36900 - 29489.5
Find the cosine and multiply.
d^2 \approx 7410.5
Subtract.
d \approx 86.08
Take the square root.
Answer: about 86.08 miles
10.
\cos \theta = \frac{18^2 + 24^2 - 32^2}{2(18)(24)}The angle between the 18 ft and 24 ft sides is across from the 32 ft side.
\cos \theta = \frac{324 + 576 - 1024}{864}Square.
\cos \theta = \frac{-124}{864} \approx -0.1435Simplify.
\theta \approx 98.3^\circ
Take the inverse cosine.
Answer: about 98.3^\circ
FAQ
What is the law of cosines formula?
It is c^2 = a^2 + b^2 - 2ab \cos C, where C is the angle between sides a and b. The same pattern works for sides a and b.
When do you use the law of cosines?
Use it for SAS, to find the third side, and for SSS, to find an angle. For AAS, ASA or SSA, use the law of sines.
How is the law of cosines related to the Pythagorean theorem?
When the angle is 90^\circ, \cos 90^\circ = 0, so the last term drops out and you get c^2 = a^2 + b^2. The Pythagorean theorem is a special case.
Can the law of cosines give two answers?
No. Each cosine value between −1 and 1 matches exactly one angle from 0^\circ to 180^\circ, so there is no ambiguous case.
Summary
- The law of cosines: c^2 = a^2 + b^2 - 2ab \cos C.
- Use it for SAS (find a side) and SSS (find an angle).
- For an angle, use \cos C = \frac{a^2 + b^2 - c^2}{2ab}.
- In SSS, find the largest angle first, then use the law of sines or the angle sum.
- A negative cosine means an obtuse angle.
Previous lesson: Ambiguous Case of the Law of Sines
Next lesson: Area of Oblique Triangles
Back to the Trigonometry Index