% horseshoe map

function [s,t,type]=hs_map(x,y)
     if (x>0)&(x<1/3) & (y>0)&(y<1)
	 t=(3/4 -1/8)+y/4;
	 s=3*x;
	 type=2;
     elseif (x>2/3)&(x<1) & (y>0)&(y<1)
	 t=(1/4 -1/8)+y/4;
	 s=3*x-2;
	 type=4;
     elseif (x>1/3)&(x<2/3) & (y>0)&(y<1)
	 t=y*log(((3/4)+(1/8)-(1/2))/((3/4)-(1/8)-(1/2)))/pi;
	 s=3*x-1;
	 z=s+i*t;
	 w=(i/2)+(i*((3/4)-(1/2)+(1/8)))*exp(pi*i*z);
	 s=real(w);
	 t=imag(w);
	 type=3;
     elseif (x<0)&(x^2+(y-.5)^2<1/4) 
	 z=x+i*y;
	 w=-(z-i/2)/4+1+i*(3/4);
	 s=real(w);
	 t=imag(w);
	 type=1; 
     elseif (x>1)&((1-x)^2+(y-.5)^2<1/4) 
	 z=x+i*y;
	 w=(z-1-i/2)/4+1+i*(1/4);
	 s=real(w);
	 t=imag(w);
	 type=5;
     else
	 s=0;
	 t=0;
	 type=0;
     end
return 
