Guide

The cosine rule

By Viktor Lassen4 min readUpdated 3 September 2026

The cosine rule lets you find a side from two sides and the angle between them, or an angle from three sides, in any triangle. Here are the three versions and both worked examples from the book.

The cosine rules are, like the sine rule, a way we can find angles and side lengths in any triangle. There are three cosine rules, one for each of the sides aa, bb and cc. Picking the right one of the three is the only real decision. After that it's inserting numbers and, when it's an angle you want, one extra step at the end.

When do I use this?

The cosine rules can be used if we either have three side lengths in the triangle and want to find some angles, or if we have an angle and the two side lengths that don't belong to the angle, that is, the two sides next to it. If instead you know an angle together with its own opposite side, it's the sine rule you want. And if the triangle has a right angle, the short formulas from sin, cos and tan in right-angled triangles are enough.

The three cosine rules

a2=b2+c2−2bc×cos⁡(A)a^2 = b^2 + c^2 - 2bc \times \cos(A)

b2=a2+c2−2ac×cos⁡(B)b^2 = a^2 + c^2 - 2ac \times \cos(B)

c2=a2+b2−2ab×cos⁡(C)c^2 = a^2 + b^2 - 2ab \times \cos(C)

The naming is the usual one: side aa is opposite corner AA, side bb opposite corner BB, side cc opposite corner CC. Notice that each rule contains exactly one angle, and it's the angle opposite the side on the left. That's how you pick: the version that contains the angle you know or want.

Worked example: finding a side

Let's look at an example:

A triangle where angle A is 35 degrees and the two sides next to it are 6 and 4. We want side a

If we have the quantities as shown on the figure, and want to find the side length aa, we can use the first cosine rule, because that's the one with angle AA in it:

a2=b2+c2−2bc×cos⁡(A)a^2 = b^2 + c^2 - 2bc \times \cos(A)

We insert our quantities in the formula. The side bb is opposite BB, so it's the side of length 66, and cc is the side of length 44:

a2=62+42−2×6×4×cos⁡(35∘)a^2 = 6^2 + 4^2 - 2 \times 6 \times 4 \times \cos(35^\circ)

That gives a2≈12.68a^2 \approx 12.68, and since we want aa and not a2a^2, we take the square root:

a=12.68≈3.56a = \sqrt{12.68} \approx 3.56

So the side aa is about 3.563.56.

Worked example: finding an angle

We could also find an angle, if we had been given three lengths:

A triangle with the three sides 7, 3 and 5. We want angle B

If we want to find angle BB on the figure above, we have to use the cosine rule that contains angle BB. We can see that the second cosine rule contains angle BB:

b2=a2+c2−2ac×cos⁡(B)b^2 = a^2 + c^2 - 2ac \times \cos(B)

So we just insert the side lengths in their places in the cosine rule. Side bb is opposite BB, so b=5b = 5, and the other two are a=3a = 3 and c=7c = 7:

52=32+72−2×3×7×cos⁡(B)5^2 = 3^2 + 7^2 - 2 \times 3 \times 7 \times \cos(B)

Now we have to solve this equation to find BB. We move everything except cos⁡(B)\cos(B) over to the other side, which gives

32+72−522×3×7=cos⁡(B)\frac{3^2 + 7^2 - 5^2}{2 \times 3 \times 7} = \cos(B)

Now, to get BB completely on its own, we take the opposite of cos on both sides, which is cos⁡−1\cos^{-1}:

cos⁡−1(32+72−522×3×7)=B\cos^{-1}\left(\frac{3^2 + 7^2 - 5^2}{2 \times 3 \times 7}\right) = B

(If this cos⁡−1\cos^{-1} doesn't quite make sense yet, it doesn't matter. It's the button that undoes cos, and you can read more about that kind of button in the guide on inverse functions.)

The fraction works out to 32+72−522×3×7=3342\frac{3^2 + 7^2 - 5^2}{2 \times 3 \times 7} = \frac{33}{42}, and the calculator gives

B≈38.21∘B \approx 38.21^\circ

So angle BB is about 38.2138.21 degrees.

Common mistakes

  • Picking a version that doesn't contain your angle. Each cosine rule has exactly one angle in it, the one opposite the side on the left. To find or use angle BB, you need the version that starts with b2b^2.
  • Putting the sides in the wrong places. The side on the left is the one opposite the angle in the rule. In the angle example, b=5b = 5 because it's opposite BB, and the other two sides fill aa and cc.
  • Using the cosine rule where the sine rule is simpler. If you know an angle and its own opposite side, the sine rule gets there in one line. The cosine rule is for three sides, or two sides and the angle between them.
  • Stopping at cos(B). cos⁡(B)=3342\cos(B) = \frac{33}{42} is not the angle. You still have to take cos⁡−1\cos^{-1} on both sides to get BB itself.

Frequently asked questions

Read next

Want to get good at maths?

Mathara explains every topic step by step with videos, exercises and personal feedback.

👉 Get started for free