function out=q2(x, N_theta2, N_phi2)

r=abs(x);
alpha=angle(x);
if N_phi2==1
   y=2;
else
   y=(round(r/2*(N_phi2)+.5)-0.5)/(N_phi2)*2;
end
theta2=alpha-acos(y/2);
theta2=round(theta2/2/pi*N_theta2)/N_theta2*2*pi;
 out=exp(1i*(theta2+acos(y/2))).*y;
 