Solving an equation with cosine of a multiple angle