Law of cosines (Khan Academy)

These are notes from the Khan Academy video series on Law of Cosines.

Solving for a side with the law of cosines

Given a triangle with sides A, B, and C and angle AB, if you know the length of A and B and angle AB, how can you calculate C?

If the triangle is a right-angle triangle, we can solve a missing side using Pythagoras Theorem:

C2=B2+A2C^2 = B^2 + A^2

For any triangle, we can use the law of cosines:

C2=B2+A22ABcos(θ)C^2 = B^2 + A^2 - 2AB \cdot \cos(\theta)

This expression makes sense because cos(90°)=0\cos(90°) = 0 . For a right-angle triangle, you can simply ignore the 2ABcos(θ)-2AB \cdot \cos(\theta) component.

Solving for an angle with the law of cosines

If the angle is unknown, we can rewrite the expression as follows:

cos(C)=a2+b2c22abcos(C) = \frac{a^2 + b^2 - c^2}{2ab}


C=acos(a2+b2c22ab)C = acos(\frac{a^2 + b^2 - c^2}{2ab})

Proof of the law of cosines

One way to solve the problem using the law of cosines is to convert them into two right triangles.

Law of Cosines

Then we can calculate the side dd knowing CAH: Cosine =Adjacent / Hypotenuse.

cos(θ)=dbd=bcos(θ)\cos(\theta)=\frac{d}{b} \Rightarrow d = b\cos(\theta)

We know that ee is e=cbcos(θ)e = c - b\cos(\theta)

Can calculate side mm since mm is opposite, we can use SOH: Sine = Opposite / Hypotenuse.

mb=sinθm=bsin(θ)\frac{m}{b}=\sin\theta \Rightarrow m=b \sin(\theta)

Now we can use Pythagorean formula:

a2=m2+e2a^2 = m^2 + e^2 a2=(bsin(θ))2+(cbcos(θ))2a^2 = (b\sin(\theta))^2 + (c-b\cos(\theta))^2

We can then multiply it out:

b2sin2θ+c22cbcosθ+b2cos2θb^2sin^2 \theta + c^2 - 2cb \cos\theta + b^2\cos^2 \theta

We can then rearrange the expression:

b2sin2θ+b2cos2θ+c22bccosθb^2 sin^2 \theta + b^2 \cos^2 \theta + c^2 - 2bc \cos \theta

Which can be rewritten as:

b2(sin2θ+cos2θ)+c22bccosθb^2(\sin^2\theta + \cos^2 \theta) + c^2 -2bc \cos \theta

Since the first part of the expression is the product of b2b^2 and the Pythagorean identity, we can reduce it to b2b^2

a2=b2+c22bccosθa^2 = b^2 + c^2 -2bc \cos \theta

And that's the formula for the law of cosines!