%@AUTEUR:Guillaume Connan
prologues:=2;

input courbes;
input geo;

color vert_e, turquoise, orange, vert_fonce, rose, vert_mer, bleu_ciel, or, rouge_v,bleu_m,bleu,bleu_f;
vert_e:=(0,0.790002,0.340007);
turquoise:=(0.250999,0.878399,0.815699);
orange:=(0.589999,0.269997,0.080004);
vert_fonce:=(0,1.4*0.392193,0);
rose:=(1.0, 0.752907, 0.796106);
bleu_ciel:=(1.2*0.529405,1.2*0.807794,1);%.2*0.921598);
or:=(1,0.843104,0);
rouge_v:=(0.829997,0.099994,0.119999);
bleu_m:=(0.7*0.529405,0.7*0.807794,0.7);%*0.921598);
bleu_f:=(0.211762,0.3231176,0.3686392);
bleu:=(0.529405,0.807794,1);

% Déclarations des constantes %
numeric xmin, xmax, ymin, ymax, N;

ux:=.5cm;  uy:=2.5cm;
xmin := -.5 ; xmax := 12;
ymin := -.1 ; ymax := 1.5;

% Définitions des axes et labels associés
vardef axes =
  drawarrow (ux*xmin,0) -- (ux*xmax,0) ; % axe des x
  drawarrow (0,uy*ymin) -- (0,uy*ymax); % axe des y
  label.lrt(btex $x$ etex,(xmax*ux,0)); % label de l'axe des x
  label.urt(btex $y$ etex,(0,ymax*uy)); % label de l'axe des y
enddef;

vardef f(expr x) =1-1/(x+1) enddef;

vardef tracee (suffix g)(expr a,b,inc) =
  save i; numeric i;
  for i=a step inc until b:
    (i*ux,f(i)*uy) ..
  endfor (b*ux,f(b)*uy)
enddef;

vardef fp(expr x) =1+(sin(x))/(x*sqrt(x)) enddef;

vardef tracep (suffix gp)(expr a,b,inc) =
  save i; numeric i;
  for i=a step inc until b:
    (i*ux,fp(i)*uy) ..
  endfor (b*ux,fp(b)*uy)
enddef;

vardef fs(expr x) =1+1/(x-1) enddef;

vardef traces (suffix gs)(expr a,b,inc) =
    save i; numeric i;
    for i=a step inc until b:
     (i*ux,fs(i)*uy) ..
    endfor (b*ux,fs(b)*uy)
  enddef;
  

beginfig(1);
  label.llft(btex $0$ etex,(-.05*ux,-.1*uy));
% L'asymptote et les horizontales
  
  path z;
  numeric e;
  e:=.15;
  
  z:= (0,(1+e)*uy)--(11.5*ux,(1+e)*uy)--(11.5*ux,(1-e)*uy)--(0,(1-e)*uy)--cycle;
  fill z withcolor bleu_ciel;
  
  draw(0,(1+e)*uy)--(11.5*ux,(1+e)*uy) withcolor bleu_m;
  label.rt(btex $y=h(x)$ etex,(11.5*ux,(1+e)*uy))withcolor bleu_f;
  label.lft(btex $\ell+\varepsilon$ etex,(-.1*ux,(1+e)*uy));
  
  draw(0,(1-e)*uy)--(11.5*ux,(1-e)*uy)withcolor bleu_m;
  label.rt(btex $y=g(x)$ etex,(11.5*ux,(1-e)*uy))withcolor 0.6white;
  label.lft(btex $\ell-\varepsilon$ etex,(-.1*ux,(1-e)*uy));
  
  label.rt(btex $y=f(x)$ etex,(11.5*ux,1*uy))withcolor bleu;
  
  draw (-.1*ux,uy)--(.1*ux,uy)withcolor bleu_m;
  draw (.1*ux,uy)--(11.5*ux,uy) dashed evenly withcolor bleu_m;
  label.lft(btex $\ell$ etex,(-.1*ux,uy));
  
  label.bot(btex $ A_g$ etex,((1/e-1)*ux,0)) ;
  draw ((1/e-1)*ux,0)--((1/e-1)*ux,(1-e)*uy) dashed evenly;
  draw ((1/e+1)*ux,0)--((1/e+1)*ux,(1+e)*uy) dashed evenly;
  label.bot(btex $ A_h$ etex,((1/e+1)*ux,0)) ;
  dotlabel.bot(btex   etex ,((1/e-1)*ux,(1-e)*uy));
  dotlabel.top(btex   etex ,((1/e+1)*ux,(1+e)*uy));
  
  draw tracee(f,0,11.5,.008) withpen pencircle scaled 1.5bp withcolor 0.6white;
  draw tracep(fp,1.3,11.5,.008) withpen pencircle scaled 1.5bp withcolor bleu;
  draw traces(fs,2.5,11.5,.008) withpen pencircle scaled 1.5bp withcolor bleu_f;
  
  draw ((1/e-1)*ux,(1-e)*uy) withpen pencircle scaled 3bp;
  axes;
endfig;
end