Solving an equation involving complementary or supplementary angles