# sqrt.ode # newtons method in the complex plane to find square roots of 1 # z^2=1 # x^2-y^2= 1 , 2*x*y=0 # draws basin boundaries # # tolerances par eps=.001 # discretization of the phase-space par dx=0,dy=0 # the two roots par r1=1,s1=0 par r2=-1,s2=0 # the functions f=x^2-y^2-1 g=2*x*y # the derivatives of the functions fx=2*x fy=-2*y gx=2*y gy=2*x # the Jacobian -- used in the inverse det=fx*gy-fy*gx # a euclidean distance function dd(x,y)=x*x+y*y # if close to the root then plot otherwise out of bounds for each root aux xp[1..2]=if(dd(x-r[j],y-s[j])