function [y,n]=PFLogistique1(x0,nmax,eps)
  mu=0.8;
  y=x0;
  deff('y=g(x)','y=mu*x-mu*x*x')  
 

   fid=mopen('Logistique1.dat','w')
  n=0;
   mfprintf(fid, '%f \n',y);
    disp(y)
  while(abs(g(y)-y)>eps & n<nmax)  
      y=g(y)  
   mfprintf(fid, '%f \n',y);
    disp(y)
      //mfprintf(6, '%f \n',y);
      n=n+1;
      //plot(y,g(y),'*')
   end  
   mclose(fid)
   
endfunction


function [y,n]=PFLogistique2(x0,nmax,eps,mu)
  y=x0;
  deff('y=g(x)','y=mu*x-mu*x.*x')  
  deff('y=h(x)','y=x')
 clf()
 x=0:0.01:1
plot(x,g(x),x,x) 
 //fig=gcf()


    
   fid=mopen(' Logistique1.dat','w')
  n=0;
  while(abs(g(y)-y)>eps & n<nmax)  
    //if (n>100) 
      A=[y g(y)];
      B=[g(y) g(y)];
      xpoly(A,B)
    sleep(300)
    //end
    y=g(y); 
    //if (n>100) 
     A=[y y];
    B=[y g(y)]; 
     xpoly(A,B)  
     sleep(300)
    //end
    
   mfprintf(fid, '%f \n',y);
    disp(y)
      n=n+1;
      //plot(y,g(y),'*')
   end  
   mclose(fid)

   
endfunction


function tracegcarcube()
    mu=3.1
  deff('y=g(x)','y=mu*x-mu*x.*x')  
  
 x=0:0.01:1
 n=size(x,2)
 plot(x,x,'b') 
  for i=1:n
     z(i)=g(x(i))
     z(i)=g(z(i))
 end
 plot(x,z,'g') 
 for i=1:n
     z(i)=g(z(i))
 end
plot(x,z,'r') 

endfunction



function [x1,x2]=racinesg2(mu)
    Delta=(mu*mu)*(mu+1)*(mu-3)
    x1=(-(mu+mu^2)+sqrt(Delta))/(-2*mu^2)
    x2=(-(mu+mu^2)-sqrt(Delta))/(-2*mu^2)
endfunction

function y=DC2(mu)
    Delta=(mu*mu)*(mu+1)*(mu-3)
    deff('y=gp(x)','y=mu-2*mu*x') 
    x1=(-(mu+mu^2)+sqrt(Delta))/(-2*mu^2)
    x2=(-(mu+mu^2)-sqrt(Delta))/(-2*mu^2)
    y=gp(x1)*gp(x2)
endfunction




function y=traceg4(mu)
     deff('y=g2(x)','y=mu^2*x*(1-x)*(1-mu*x*(1-x))') 
     deff('y=g4(x)','y=mu^2*g2(x)*(1-g2(x))*(1-mu*g2(x)*(1-g2(x)))') 

y=zeros(1,101)
for i=1:101
    a=0.01*i-0.01
    disp(a)
    y(i)=g4(a)
end
x=0:0.01:1
plot(x,y)
plot(x,x)
endfunction

function y=DC4(mu)// renvoile la dérivée du cycle d'ordre 4 (pour g4)
   p=poly([0 mu -mu],'x','c')
   q=poly([0 1],'x','c')
   p2=mu*p-mu*p^2
   p3=mu*p2-mu*p2^2
   p4=mu*p3-mu*p3^2 // c'est g4
   h=p4-q
   [b,c]=racinesg2(mu) // cycle d'ordre 2
   d=1-(1/mu)
   r=roots(h)
   rr=zeros(1,4)
   compt=1
   for i=1:16
       a=r(i)
       vv=(abs(imag(a))<0.0001)
       disp(vv)
       if vv
           if (abs(a)>0.0)
               if (abs(a-d)>0.001)
                   if (abs(a-b)>0.001)
                       if (abs(a-c)>0.001)
                        disp(a)
                        rr(compt)=a
                        compt=compt+1
                        end
                     end    
                  end
            end
        end
   end               
   r1=rr(1)
   r2=rr(2)
   r3=rr(3)
   r4=rr(4)
deff('y=dg(x)','y=mu*(1-2*x)')
y=dg(r1)*dg(r2)*dg(r3)*dg(r4)
endfunction
