%@AUTEUR:Guillaume Connan
prologues:=2;

verbatimtex
%&latex
\documentclass{article}
\begin{document}
etex

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);


beginfig(1);
% GRAPHIQUE f-1   
  vardef axes =
    drawarrow (ux*xmin,0) -- (ux*xmax,0); % axe des x
    drawarrow ((0,uy*ymin) -- (0,uy*ymax))  ; % axe des y
  enddef;
  
% Déclarations des constantes %
  ux:=0.8cm; uy:=ux;
  xmin:=-3.5; xmax:=4.5;
  ymin:=xmin; ymax:=xmax;
  coefficient:=1; % coefficient d'échelle
  
%Tracé des axes
  axes;
  
% Définitions de la fonction
  vardef f(expr x) :=-2.5/x enddef;
  
  vardef trace (suffix F)(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;
  
% Tracé des différentes courbes
  numeric pas, seuil, seuilbis, abscisse;
  pas:=0.009;
  seuil:=3.75;
  seuilbis:=1.25;
  abscisse:=seuil-0.5;
  
  xA:=abscisse;
  yA:=f(abscisse);
  xB:=f(abscisse);
  yB:=abscisse;
  xD:=xmin/2;
  yD:=xD;
  xE:=0.75*seuil;
  yE:=xE;
  
  pair A, B, C, D, E, Ax, Ay, Bx, By;
  A:=(xA*ux,yA*uy);
  B:=(xB*ux,yB*uy);
  D:=(xD*ux,yD*uy);
  E:=(xE*ux,yE*uy);
  Ax:=A yscaled 0;
  Ay:=A xscaled 0;
  Bx:=B yscaled 0;
  By:=B xscaled 0;
  
  C=whatever[A,B]=whatever[D,E];
  
  draw trace(F,f(seuilbis),f(seuil),pas); % tracé de la courbe de f
  draw trace(F,seuilbis,seuil,pas); % tracé de la courbe de f
  
  draw  (A--Ax) dashed evenly withcolor bleu;
  draw ((0,0)--Ax) withpen pencircle scaled 2bp withcolor bleu;
  draw (A--Ay) dashed evenly withcolor bleu_f;
  draw ((0,0)--Ay) withpen pencircle scaled 2bp withcolor bleu_f;
  
  draw  (B--Bx) dashed evenly withcolor bleu_f;
  draw ((0,0)--Bx) withpen pencircle scaled 2bp withcolor bleu_f;
  draw (B--By) dashed evenly withcolor bleu;
  draw ((0,0)--By) withpen pencircle scaled 2bp withcolor bleu;
  
  draw (D--E) withcolor 0.55white dashed withdots withpen pencircle scaled 2.5bp;
  draw (A--B) withpen pencircle scaled 1bp;
  label(btex $\Vert$ etex, 2/3[A,C]);
  label(btex $\Vert$ etex, 2/3[B,C]);
  label.lrt(btex $\Gamma_f$ etex, (seuilbis*ux,f(seuilbis)*uy));
  label.ulft(btex $\Gamma_{f^{-1}}$ etex, (f(seuilbis)*ux,seuilbis*uy));
  draw (((1,0)--(1,1)--(0,1)) zscaled (5*unitvector(E-D)) shifted C);
  dotlabel.lrt(btex $(x,y)$ etex, A);
  dotlabel.ulft(btex $(y,x)$ etex, B);
  label.top(btex $x$ etex, Ax);
  label.llft(btex $y$ etex, Ay);
  label.urt(btex $x$ etex, By);
  label.ulft(btex $y$ etex, Bx);
  
  label.urt(btex $y=x$ etex, E) withcolor 0.55white;

endfig;
end