#include<fstream>
using namespace std;
void complexpow(double* x,double* y,int n)//计算Z的N次
{
double x0=*x,y0=*y,temp;
for(int i=0;i<n-1;i++)
{
temp=*x;
*x=*x*x0-*y*y0;
*y=temp*y0+*y*x0;
}
}
int main()
{
double x,y,CR,CI;
double i,j,k;
ofstream fout("output.txt");
CR=-0.12;//控制参数C的实部
CI=0.81;//控制参数C的虚部
for(i=-1.6;i<1.6;i+=0.001)
for(j=-1.5;j<1.5;j+=0.001)
{
x=i;y=j;
for(k=0;k<50&&(x*x+y*y)<25;k++)
{
complexpow(&x,&y,6);//这里表示Z=Z^6
x=x+CR;
y=y+CI;
}
if(x*x+y*y<25)
fout<<i<<"\t"<<j<<endl;
}
fout.close();
return 0;
}
左图局域放大后得到右图,可以看到右图和左图的自相似。