Prove and apply Euclid VI.31, generalizing the Pythagorean theorem to any similar shapes on the sides of a right triangle.