NOTICE: Citizendium is still being set up on its newer server, treat as a beta for now; please see here for more. Citizendium - a community developing a quality comprehensive compendium of knowledge, online and free. Click here to join and contribute—free Click here to participate in the November 2016 election. CZ thanks our previous donors. Donate here. Treasurer's Financial Report -- Thanks to our content contributors. --

# Tetration/Code/SLOGappro50

< Tetration‎ | Code(Redirected from SLOGappro50.jpg/code)

(CC) Image: Dmitrii Kouznetsov
SLOGappro50
// Generator of Image:SLOGappro50.jpg
// Need also functions
// ContourPlot/code/conto.cin  (function which draws a level)
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define DB double
#define DO(x,y) for(x=0;x<y;x++)
#include <complex.h>
#define z_type complex<double>
#define Re(x) x.real()
#define Im(x) x.imag()
#define I z_type(0.,1.)
z_type Zo=z_type(.31813150520476413, 1.3372357014306895);
z_type Zc=z_type(.31813150520476413,-1.3372357014306895);
z_type fslog(z_type z1)
{ int K=61,k;
DB DER0[61]={
1.419225215504513748
,-0.02606629029752273799
, 0.00173304781808079292
,-0.00001952130725341244
,-0.00006307006449600553
, 0.00002567895998206714
,-0.00000559010026631166
,-0.00000007279711570355
, 0.00000065148872447963
,-0.00000027698137547945
, 0.00000003111805388071
, 0.00000002940887492440
,-0.00000001896929304451
, 0.00000000351784294580
, 0.00000000204270380369
,-0.00000000171995244014
, 0.00000000039882033861
, 0.00000000019327859119
,-0.00000000019113316803
, 0.00000000004947300288
, 0.00000000002293216922
,-0.00000000002462024052
, 0.00000000000666293790
, 0.00000000000321953305
,-0.00000000000353994150
, 0.00000000000095693911
, 0.00000000000051233696
,-0.00000000000055345036
, 0.00000000000014403108
, 0.00000000000008947807
,-0.00000000000009233287
, 0.00000000000002235177
, 0.00000000000001674522
,-0.00000000000001620799
, 0.00000000000000351749
, 0.00000000000000329991
,-0.00000000000000296147
, 0.00000000000000055023
, 0.00000000000000067615
,-0.00000000000000055844
, 0.00000000000000008305
, 0.00000000000000014273
,-0.00000000000000010792
, 0.00000000000000001140
, 0.00000000000000003084
,-0.00000000000000002125
, 0.00000000000000000119
, 0.00000000000000000678
,-0.00000000000000000424
,-0.00000000000000000001
, 0.00000000000000000151
,-0.00000000000000000085
,-0.00000000000000000006
, 0.00000000000000000034
,-0.00000000000000000017
,-0.00000000000000000003
, 0.00000000000000000008
,-0.00000000000000000003
,-0.00000000000000000001
, 0.00000000000000000002
,-0.00000000000000000001
};
//#include "taok.cin"
z_type z=z1-1.;
z_type s=0.;
z_type t=1;
for(k=0;k<=50;k++) { s+=DER0[k]*t; t*=z; }
s+=log(z1-Zo)/Zo+log(z1-Zc)/Zc;
//printf("F returns %18.14f +\n",Re(s));
return s;
}
#include "conto.cin"
main(){ int j,k,m,n; DB x,y, p,q, t; z_type z,c,d, cu,cd;
z=0.;
z=fslog(z);
printf("fslog(0)= %18.14f  %18.14f\n",Re(z),Im(z));
//getchar();
int M=300,M1=M+1;
int N=300,N1=N+1;
DB X[M1],Y[N1], g[M1*N1],f[M1*N1], w[M1*N1]; // w is working array.
char v[M1*N1]; // v is working array
fprintf(o,"202 202 translate\n 100 100 scale\n");
DO(m,M1) X[m]=-2+.02*m;
DO(n,N1) Y[n]=-2+.02*n;
for(m=-2;m<3;m++) {	if(m==0){M(m,-2.1)L(m,2.1)}
else	{M(m,-2)L(m,2)}
}
for(n=-2;n<3;n++) {M(  -2,n)L(2,n)} fprintf(o,".002 W 0 0 0 RGB S\n");
z_type tm,tp,F[M1*N1];
DO(m,M1)DO(n,N1){	g[m*N1+n]=9999;
f[m*N1+n]=9999;
}
for(m=0;m<M1;m++){x=X[m];
DO(n,N1){y=Y[n]; z=z_type(x,y);
c=fslog(z);
F[m*N1+n]=c;
}
}
DO(m,M1)
DO(n,N1){
c=(F[m*N1+n]); p=Re(c); q=Im(c);
if(p>-999 && p<999) g[m*N1+n]=p;
if(q>-999 && q<999) f[m*N1+n]=q;
}
p=4;q=4;
conto(o,f,w,v,X,Y,M,N, ( -3     ),-p,p); fprintf(o,".002 W 1 0 0 RGB S\n");
conto(o,f,w,v,X,Y,M,N, (-2.     ),-p,p); fprintf(o,".002 W 1 0 0 RGB S\n");
for(n=2;n<10;n+=2)conto(o,f,w,v,X,Y,M,N, (-2.+.1*n),-p,p); fprintf(o,".001 W 0 1 0 RGB S\n");
conto(o,f,w,v,X,Y,M,N, (-1.     ),-p,p); fprintf(o,".002 W 1 0 0 RGB S\n");
for(n=2;n<10;n+=2)conto(o,f,w,v,X,Y,M,N, (-1.+.1*n),-p,p); fprintf(o,".001 W 0 1 0 RGB S\n");
conto(o,f,w,v,X,Y,M,N, (0.      ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
for(n=2;n<10;n+=2)conto(o,f,w,v,X,Y,M,N, (    .1*n),-p,p); fprintf(o,".001 W 0 1 0 RGB S\n");
conto(o,f,w,v,X,Y,M,N, ( 1.     ),-p,p); fprintf(o,".002 W 0 0 1 RGB S\n");
for(n=2;n<10;n+=2)conto(o,f,w,v,X,Y,M,N, ( 1.+.1*n),-p,p); fprintf(o,".001 W 0 1 0 RGB S\n");
conto(o,f,w,v,X,Y,M,N, ( 2.     ),-p,p); fprintf(o,".002 W 0 0 1 RGB S\n");
conto(o,f,w,v,X,Y,M,N, ( 3      ),-p,p); fprintf(o,".002 W 0 0 1 RGB S\n");
/*
conto(o,g,w,v,X,Y,M,N, (-33.     ),-p,p); fprintf(o,".001 W 1 0 1 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-32.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-30.     ),-p,p); fprintf(o,".002 W 0 1 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-28.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-26.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-24.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-22.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-20.     ),-p,p); fprintf(o,".002 W 1 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-18.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-16.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-14.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-12.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-10.     ),-p,p); fprintf(o,".002 W 1 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-8.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-6.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-4.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
*/
conto(o,g,w,v,X,Y,M,N, (-3.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-2.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
for(n=2;n<10;n+=2)conto(o,g,w,v,X,Y,M,N,(-2.+.1*n),-p,p); fprintf(o,".001 W 1 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (-1.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
for(n=2;n<10;n+=2)conto(o,g,w,v,X,Y,M,N, (-1.+.1*n),-p,p); fprintf(o,".001 W 1 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, (0.      ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
for(n=2;n<10;n+=2)conto(o,g,w,v,X,Y,M,N, (    .1*n),-p,p); fprintf(o,".001 W 0 0 1 RGB S\n");
conto(o,g,w,v,X,Y,M,N, ( 1.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
for(n=2;n<10;n+=2)conto(o,g,w,v,X,Y,M,N, ( 1.+.1*n),-p,p); fprintf(o,".001 W 0 0 1 RGB S\n");
conto(o,g,w,v,X,Y,M,N, ( 2.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
conto(o,g,w,v,X,Y,M,N, ( 3.     ),-p,p); fprintf(o,".002 W 0 0 0 RGB S\n");
fprintf(o,"showpage\n\%\%\%Trailer"); fclose(o);
z=-1.;c=fslog(z); printf("slog(-1)=%18.14f %18.14f\n",Re(c),Im(c));
z=0.; c=fslog(z); printf("slog( 0)=%18.14f %18.14f\n",Re(c),Im(c));
z=1.; c=fslog(z); printf("slog( 1)=%18.14f %18.14f\n",Re(c),Im(c));
//	  system( "ggv SLOGappro50.eps &"); // for linux
system("open SLOGappro50.eps");   // for macintosh
system("ps2pdf SLOGappro50.eps");
getchar(); system("killall Preview"); //for macintosh
}
//end of generator of SLOGappro50.eps