The Law of Cosines is used to help find the angles and sides of a triangle, through the use of ratios.

cos C = (a2+b2-c2)/(2ab)

another form: c2 = a2+b2-2ab(cos C)

The Law of Cosines, or as it's sometimes known the cosine rule, says that a triangle with sides of length a, b, and c and angles A, B, and C respectively opposite those sides obeys the following relation:

a2 = b2 + c2 - 2ab*Cos(A)

See below for some diagrams.

Since the Law of Cosines relates the lengths of all three sides of a triangle and one of the angles, you generally use it if you know three out of four of those quantities. Then you can solve for the remaining unknown. So, you would use the Law of Cosines if you knew the lengths of all the sides of a triangle and wanted to know one of the angles, or if you knew an angle and the lengths of two sides and wanted to know the length of the third. If, on the other hand, you need to relate two sides and two angles then The Law of Sines (a.k.a. the sine rule) is what you're looking for.

You don't have to remember the Law of Cosines for a right triangle, because in that case it just gives other things you already know about right triangles. If A is the right angle, then Cos(A)=0, so the Law of Cosines just becomes the Pythagorean Theorem1. If A is one of the other (acute) angles, a little algebra shows that the Law of Cosines will just give us the normal "adjacent over hypotenuse" definition of cosine. Finally, if A=0, then a, b, and c are all colinear, and, since Cos(A)=1, it just tells us the the fact that a2 = (b - c)2. That makes sense because when A=0, a is just the difference in length between b and c. So we only ever really have to use the Law of Cosines when we're dealing with a triangle with no right angles.

I used to hate the Law of Cosines, because I could never remember it or understand where it came from. One day I realized, though, that if you know about vectors and the dot product then it's very simple to figure out. That was hardly an original discovery, but now I'd like to share first an explanation using vectors, then a geometrical argument using the Pythagorean Theorem.

A Vector Argument

In terms of vectors we can describe a triangle as three vectors, a, b, and c with lengths a, b, and c, respectively, that have the relationship that a + b = c. We can rewrite the relationship as a = c - b. Then, if we use * to represent the dot product,

a*a = a2 = (c - b)*(c - b)

Distributing yields,

a2 = c*c + b*b - c*b - b*c

But remember

c*b = b*c = bc*Cos(A),

since A must be the angle between b and c (making it opposite A). Continuing we get

a2 = b2 + c2 - 2bc*Cos(A)

So there we have the Law of Cosines, just by using the dot product. I should note that here I took the definition of cosine to be Cos(A) = b*c/(bc), when A is the angle between b and c. In that case, as you saw, the proof of the Law of Cosines is pretty trivial, but that's because we already built most of the information into the definition of cosine and the dot product. So, this vector argument is technically a proof, but it's a trivial one.

A Standard Geometric Argument

The following are diagrams of the 3 possible, qualitatively different situations that can arise. Basically, since A + B + C = 180 degrees (a.k.a. π radians), either A, B, or C is obtuse, each leading to a qualitatively differant picture. Here they are:


                   C                                                     C
                  /|\                                                 _ /|
                /  | \                                            _ /   /.
              /    |  \                                       _ /     /  .
          b /      |   \                               b  _ /       /    .
          /        |d   \ a                           _ /         /      .
        /          |     \                        _ /           / a      . d
      /            |      \                   _ /             /          .
    /              |       \              _ /               /            .
  /      f        Z|    e   \           /        c      B /       e      .
 ------------------+----------         ------------------+................
A                c            B       A                f                  Z



                                    C
                                _ /|
                            _ /   /.
                        _ /     /  .
                 a  _ /       /    .
                _ /         /      .
            _ /           / b      . d
        _ /             /          .
    _ /               /            .
  /        c      A /       f      .
 ------------------+................
B                e                  Z

If we have any triangle with sides a, b, and c, we can move it so that the triangle is above the x-axis and side c of the triangle falls on the x axis. Recall that we label the vertices of the triangle A, B, and C, each of which is opposite from the side with the similar label. For now, let's assume A is acute. Now, we add an altitude (a vertical line from C that meets the x-axis at a right angle) connecting the vertex C (the only one not on the x-axis) with the x axis. Call the point where the altitude meets the x-axis Z. Let us call the altitude, d, call the line connecting vertex B with Z, e, and call the line connecting vertex A with Z, f. Now, a, d, and e form a right triangle, so

a2 = e2 + d2. (Eq 1)

Also, b, d, and f form a right triangle and A is the angle between b and f, so

f = b*Cos(A). (Eq 2)

and b2 = f2 + d2. (Eq 3)

Now we can solve equation 3 for d2 and plug that in to equation 1 giving

a2 = e2 + b2 - f2 (Eq 4)

Now the length of e is the difference of the lengths of f and c, so

e2 = (f - c)2 = f2 + c2 - 2fc (Eq 5)

So, then plugging equation 5 into equation 4 we get

a2 = b2 + c2 - 2fc

and with equation 2 that becomes

a2 = b2 + c2 - 2bc*Cos(A)

which proves the Law of Cosines. Now, we assumed that A is acute here, but if A is obtuse, all that does is change equation 2 to f = -b*Cos(A) and it means that e is the sum of the lengths of c and f, rather than the difference. If you go back through the derivation with these facts, you will find the same result.

This is the basic sketch of a proof. I call it an argument because I am appealing to geometric intuition here, rather than doing a rigorous proof, and I have not made all of the assumptions clear. In fact, we have implicitly assumed Euclid's fifth postulate without stating it, which is why the Law of Cosines as stated here only holds for Euclidean geometry and must be modified in non-euclidean geometry.


1Usually the Pythagorean Theorem is used to prove the Law of Cosines, so then it would be circular to use the Law of Cosines to prove the Pythagorean Theorem.


I tried to make the vector presentation accessible to anyone who knows about vectors and dot products. If you are in that group, but the write-up still seems unclear, please /msg me and let me know.

Log in or register to write something here or to contact authors.