The cosine law states that in any triangle $ABC$, \[1.\;\;\;\cos A=\frac{b^2+c^2-a^2}{2bc}\] \[\text{or,}\;\; a^2=b^2+c^2-2bc\cos A\] \[2.\;\;\;\cos B=\frac{c^2+a^2-b^2}{2ca}\] \[\text{or,}\;\; b^2=c^2+a^2-2ca\cos B\] \[3.\;\;\;\cos C=\frac{a^2+b^2-c^2}{2ab}\] \[\text{or,}\;\; c^2=a^2+b^2-2ab\cos C\]
Let $ABC$ be a triangle placed in the standard position with the vertex $A$ at the origin and the side $AB$ along the positive x-axis. Let us denote the angle $BAC$, $CBA$, $ACB$ of the triangle $ABC$ by $A$, $B$, $C$ respectively; and the lengths of the sides $BC$, $CA$, $AB$ by $a$, $b$, $c$ respectively.
Draw $BN\perp AC$, then \[\cos A=\frac{ON}{OB}=\frac{ON}{c}\] \[\therefore ON=c\cos A\] and, \[\sin A=\frac{BN}{OB}=\frac{BN}{c}\] \[\therefore BN=c\sin A\]
Then, the coordinates of $A$, $C$ and $B$ are $(0,0)$, $(b,0)$ and $(c\cos A, c\sin A)$ respectively.
Now, using distance formula to find the length of $BC$, \[BC=\sqrt{(c\cos A-b)^2+(c\sin A-0)^2}\] \[a=\sqrt{c^2\cos^2A-2bc\cos A+b^2+c^2\sin^2A}\] \[a^2=c^2-2bc\cos A+b^2\] \[2bc\cos A=b^2+c^2-a^2\] \[\therefore\cos A=\frac{b^2+c^2-a^2}{2bc}\]
This same formula can also be proved if the triangle $ABC$ lies in the second or third quadrant in which the coordinates of $A$, $C$ and $B$ are $(0,0)$, $(-b,0)$ and $(-c\cos A, \pm c\sin A)$ respectively. And, the similar follows for the fourth quadrant where the coordinates of $A$, $C$ and $B$ are $(0,0)$, $(b,0)$ and $(c\cos A, -c\sin A)$.
Again, by placing the other angles $B$ and $C$ in the standard position, we can prove that \[\cos B=\frac{c^2+a^2-b^2}{2ca}\] and, \[\cos C=\frac{a^2+b^2-c^2}{2ab}\]
[Also see: Vector Method to Prove the Cosine Law]
In particular, if $A$ is right angle, then \[\cos 90°=\frac{b^2+c^2-a^2}{2bc}\] \[\therefore a^2=b^2+c^2\] This is the Pythagorean theorem.
Previous: The Sine Law
Next: The Projection Law