Serega.cin
Jump to navigation
Jump to search
// serega.cin is the numerical C++ implementation of functions // Serega function and ArcSerega.
/* //headers recommended: #include<math.h> #include<stdio.h> using namespace std; #include <complex> // #include"ado.cin" #include "conto.cin"
#define DO(x,y) for(x=0;x<y;x++) #define DB double #define z_type complex<double> #define Re(x) (x.real()) #define Im(x) (x.imag()) */ // Warining: non-holomorphic functions below!
z_type Serega(z_type z){ DB x,y, p,q, r,s,c; int n; x=Re(z); y=Im(z); r=exp(y); s=sin(x); c=cos(x); p=x-r*s; q=y+r*c; return z_type(p,q); }
z_type ArcSerega(z_type z){ DB x,y ,X,Y,X0,Y0, r,s,c, rc,rs, dX, dY; int n; X0=Re(z); Y0=Im(z); r=exp(Y0-1.); s=sin(X0); c=cos(X0); rc=r*c; rs=r*s; DO(n,8) { r=exp(y - exp(-.5*n)); s=sin(x); x=X0+r*s; y=Y0-r*cos(x); if(y>0){ x-=s*(1.+y); y=0.;} } DO(n,32){ r=exp(y - exp(-.5*(2.*n+8.))); c=cos(x); s=sin(x); rc=r*c; rs=r*s; X=x-rs; dX=X-X0; Y=y+rc; dY=Y-Y0; DB d=1.-r*r; d*=1.01; x-= ( (1+rc)*dX + rs *dY )/d; y-= ( rs *dX +(1-rc)*dY )/d; if(y>0){ return z_type(99., 99.);} //99 is errorcode; feel free to change it to anything more suitable. } return z_type(x,y); }
References