Use real_imag here instead of duplicating the logic.