Deriving the Law of Cosines Follow these steps to derive the law of cosines. 1. The relationship between the side lengths in AABD is 2²=²+h² by the Pythagorean theorem 2. The relationship between the side lengths in ACBD is a² = (b-x)² +h² by the law of sines