The Law of Cosines
The law of cosines is the Pythagorean theorem with a correction for angles that aren't : . It solves the two cases the law of sines can't start, two sides with the angle between them, and three sides.
What the symbols mean
- Side c
The side across from angle C.
- Angle C
The angle between sides a and b. At 90° the correction 2ab cos C is zero and this is Pythagoras.
Explanation
The law of cosines is simply the Pythagorean theorem for triangles that don't have a right angle. looks busy, but it's two pieces: (exactly what Pythagoras would say) and a correction, , that adjusts for how far angle is from . Here is the angle between sides and , and is the side across from it. When , , the correction disappears, and you're back to . It's an old friend with one extra term; bear with it.
Where it comes from. Put the triangle on a coordinate grid. Set vertex at the origin and lay side along the positive -axis, so vertex is at . Vertex is a distance from the origin in the direction of angle , so it's at , the unit circle point scaled up by . Side is the distance from to , so by the distance formula
Expand the first square: . Add and group the terms:
because (see Fundamental Identities). Nothing in that argument needed to be acute, so it holds for every triangle.
Reading the correction. Think of sides and as two rods joined by a hinge at . Close the hinge to an acute angle and , so you subtract: is shorter than the Pythagorean value. Open it past and , so subtracting a negative adds: is longer. At the extremes it makes sense too: as , , so (the rods fold onto each other), and as , (the rods lie end to end). There's an animation further down that opens the hinge.
When to use it.
- SAS (two sides and the angle between them): plug straight in to get the third side.
- SSS (three sides): solve for an angle, , then take arccos.
In the SSS case there's no ambiguity. Arccos answers with angles from to , exactly the angles a triangle can have, and cosine's sign tells acute from obtuse (negative means obtuse). Sine can't do that, which is why the Law of Sines had an ambiguous case. A good plan for SSS: find the largest angle first, across from the longest side, with the law of cosines. The other two angles must then be acute, so the law of sines is safe for them.
A common mistake. It's tempting to work left to right and compute . It isn't that: is one product, so multiply by first and then subtract it from . A second trap in SSS: the side by itself on the left of must be the side across from the angle you want. Put the wrong side there and you get a different angle.
The same calculation, with arrows instead of triangle sides, becomes the dot product formula later in this course (see The Dot Product and Angles).
See it
Worked examples
In a triangle, cm, cm and the angle between them is . Find .
- 1
We know two sides and the angle between them (SAS). No side has its opposite angle known, so the law of sines has nothing to start from. The law of cosines does.
A triangle has sides , and . Find all three angles.
- 1
Start with the largest angle. It's across from the longest side, . Call it , with , , .
Practice
Type your answer and check it. Solve them all to complete the lesson.
A triangle has , and . Find exactly.
A triangle has sides , and . Find its largest angle, in degrees.
In a triangle, . What can you say about angle ?
A robot arm has an upper link cm long and a forearm cm long, and the angle between them at the elbow is . How far is the gripper from the shoulder, in cm to one decimal place?
A small plane flies km, turns to the left, and flies km more. How far is it from where it started, in km to one decimal place?
A triangle has , and . Find its smallest angle, in degrees to two decimal places.
A roof truss has two rafters, each m long, meeting at the peak, and their lower ends sit on walls m apart. Find the angle at the peak, in degrees to two decimal places.
The hardest one here. Get it, and you've got this lesson.
Two cables pull on a bolt, one with N and one with N, and the angle between the cables is . Find the size of the combined pull (in N) and the angle it makes with the N cable (in degrees). Give both to two decimal places.
Where it's used
A two-link robot arm reaches a target only if the target's distance fits the triangle its links can make, and the elbow angle comes straight out of the law of cosines: . Air traffic control uses it for the distance between two planes from their radar ranges and the angle between them, GPS-free surveying uses it to close a traverse, and structural engineers use it to get member lengths and angles in trusses.