I, the copyright holder of this work, release this work into the public domain. This applies worldwide. In some countries this may not be legally possible; if so: I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.
C++ code
#include<iostream>#include<fstream>#include<cmath>#include<complex>usingnamespacestd;doublesmall=1e-14;doublemylog(double);intmain(){doubleA=-5,B=5;intN=1000;doubleh=(B-A)/(N-1);doubletheta0=2*M_PI/(N-1.0);ofstreammfile("data.txt");for(inti=0;i<N;i++){doubler=exp(A+i*h);for(intj=0;j<N;j++){doubletheta=j*theta0;complex<double>z2=polar(r,theta);complex<double>root=sqrt(25.0*z2*z2-12.0*(z2*z2*z2+1.0));complex<double>z11=(-5.0*z2+root)/6.0;complex<double>z12=(-5.0*z2-root)/6.0;doublea1=mylog(abs(z11));doublea2=mylog(abs(z12));doubleb=mylog(abs(z2));mfile<<a1<<' '<<b<<endl;mfile<<a2<<' '<<b<<endl;}}mfile.close();return0;}doublemylog(doublex){if(x<0){cerr<<"Error in log, negative x!"<<endl;exit(0);}if(x<small){returnlog(small);}returnlog(x);}
Matlab code which reads the data output by the C++ code and graphs it