%polynomial renormalization of logistic function.
N = input('N=0,1 or 2   ')
hold on
A0=2;
A1=1+5^(1/2);
A2=3.498562;
A3=3.554641;
A4=3.566667;
A5=3.569244;
A6=3.569793;
A7=3.569913;
q=[-1 0 .25];
d= -2.5029;
a=[1/d 0];
b=(1/d)*a;
c=(1/d)*b;
g00=A0*q-[0 0 .5];
h01=A1*q-[0 0 .5];
j01=composite(h01,h01);
k01=composite(j01,a);
g01=d*k01;
h02=A2*q-[0 0 .5];
j0=composite(h02,h02);
j02=composite(j0,j0);
k02=composite(j02,b);
g02=d*d*k02;
h03=A3*q-[0 0 .5];
j031=composite(h03,h03);
j032=composite(j031,j031);
j03=composite(j032,j032);
k03=composite(j03,c);
g03=d*d*d*k03;

y0=polyval(g00,x);
z0=polyval(g01,x);
w0=polyval(g02,x);
u0=polyval(g03,x);
g10=A1*q-[0 0 .5];
h11=A2*q-[0 0 .5];
j11=composite(h11,h11);
k11=composite(j11,a);
g11=d*k11;
h12=A3*q-[0 0 .5];
j1=composite(h12,h12);
j12=composite(j1,j1);
k12=composite(j12,b);
g12=d*d*k12;
h13=A4*q-[0 0 .5];
j131=composite(h13,h13);
j132=composite(j131,j131);
j13=composite(j132,j132);
k13=composite(j13,c);
g13=d*d*d*k13;

y1=polyval(g10,x);
z1=polyval(g11,x);
w1=polyval(g12,x);
u1=polyval(g13,x);

g20=A2*q-[0 0 .5];
h21=A3*q-[0 0 .5];
j21=composite(h21,h21);
k21=composite(j21,a);
g21=d*k21;
h22=A4*q-[0 0 .5];
j2=composite(h22,h22);
j22=composite(j2,j2);
k22=composite(j22,b);
g22=d*d*k22;
h23=A5*q-[0 0 .5];
j231=composite(h23,h23);
j232=composite(j231,j231);
j23=composite(j232,j232);
k23=composite(j23,c);
g23=d*d*d*k23;
y2=polyval(g20,x);
z2=polyval(g21,x);
w2=polyval(g22,x);
u2=polyval(g23,x);
if (N ==0) 
	plot(x,y0)
	plot(x,z0,'g')
	plot(x,w0,'m')
	plot(x,u0,'k')
elseif (N==1)
	plot(x,y1)
	plot(x,z1,'g')
	plot(x,w1,'m')
	plot(x,u1,'k')
else 
	plot(x,y2)
	plot(x,z2,'g')
	plot(x,w2,'m')
	plot(x,u2,'k')
end
