% function MOBIUS 
% returns the image of the point z in the Riemann sphere
% by the Mobius transformation defined by the 2 by 2 matrix matrix M  

function Z = mobius(M,z)
if abs(z)==Inf 
    Z=M(1,1)/M(2,1); 
elseif M(2,1)*z+M(2,2)==0;
    Z=Inf; 
else 
Z=(M(1,1)*z+M(1,2))/(M(2,1)*z+M(2,2));
end
end