Contents
As far as you are concenrened at this basic level of mathematics, the purpose of the so called law of cosines is to make it easier to work with triangles that are not very "neat". What do we mean by "neat"? Well, a "neat" triangle is one that is basically a right triangle and we can easily use the pythagorean theorem to find out information, such as the angles or sides, of the triangle. A not so neat triangle is one that is not right, and in fact it might not be pretty at all! It migh have all unequal sides and no 90 degree angles. In such terrible and miserable cases, the law of cosines is usually your only friend!
This law basically provides us with a mathetmatical equation that relates the three sides of a triangle and one of its angles. In essense - as you shall see in a bit - it is no different from the pythagorean theorme. In fact, it is a little bit more general than the pythagorean theorm in the sense that it applies to basically any kind of triangle (right tringle or some odd triangle).
Consider the following picture of a general triangle with the sides labled as a, b, and c:

The law of cosines for the above triangle relates the three sides to the angle that we have labeled as q as follows:
c2 = a2 + b2 - 2a.b.Cos(q)
The angle q is the angle that is opposite to the side labled c. This is an imporant point to keep in mind. It is good to look at the variables in the above equation and compare it to the drawn figure above.
NOTE: This relationship is general; it applies to all triangles. For instance, we can check to see that it applies to right triangles. Suppose that we have a right triangle, with side c as the hypotentuse (i.e., the longest side). Then the angle q = 90º, and we know that the cosine of 90º is equal to zero (see trig sections if you need a review of this). In such a case the third term on the right side equals zero, and we recover the pythagorean relation, namely: c2 = a2 + b2. The pythagorean theorem thus applies only to right triangles whereas the law of cosines can be applied to any triangle.
Here are some nice examples to help illustrate situations in which the use of the law of cosines is a lot simpler and saves tons and tons of geometric and algebraic manipulations..
Example # 1: In order for Mary to travel to work from home she has to get on her bike and go 20 km directly east, and then she has to go 10 km in a direction that is directly north-east (45º north of east). The county that she lives in is trying to decide whether they should build a road that goes straight from the area where she lives to the area where she works at. How many kilometers of travel will Mary save on each trip if this road is built?
Solution: If we draw a schematic figure for this situation we note that immediately we are encoutnered with a the situation in which we have not so "neat" a triangle! Part 1 of the path to work, going directly east, is labeled as a = 20 km. Part 2 of the path, going NE, is labeled as b = 10 km. The fact that Part 2 points 45º north of east allows us to calculate the angle q inside the triangle, as shown below. We simply subracact 45 from 180.
Now we know a, we know b, and we know the angle between them. We can put this information in the law of cosines to get the side c of the triangle:
c2 = a2 + b2 - 2a.b.Cos(q)
c2 = (20 km)2 + (10 km)2 - 2.(10km)(20km)Cos
(135º)
c2 = 400 km2 + 100 km2 - 400 x (-0.7071)
km2
c2 = 500 km2 + 282.84 km2
c2 = 782.84 km2
Taking the square root of both sides we get: c = 28 km. Note that I have rounded off the final answer to two significant figures and that the units came out in km, which is expected. Thus, the person will save about 2 kilometers in each direction since without the alternate path she will be traveling 30 km.