solving an equation with common bases