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

%  Différentielle

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

ux:=1.3cm;
uy:=1.3cm;
xmin := -.5; xmax := 4.5;
ymin := -.5; ymax := 3;

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


beginfig(1);

  axes; label.llft(btex $0$ etex,(-.1*ux,-.15*uy));
  
% Courbes
  
  path p,q;
  p=(0,0){dir10}..(3.5*ux,3*uy);
  q=(.2*ux,.5*uy)--(4.5*ux,1.5*uy);
  
  draw p withpen pencircle scaled 1.2bp withcolor bleu_m;
  
  label.rt(btex $\Gamma$ etex,(3.5*ux,3.2*uy));
  
% Point d'intersection
  
  pair A;
  A=(p intersectionpoint q);
  
  draw A withpen pencircle scaled 3.5bp;
  
  label.ulft(btex A etex,A shifted (.1*ux,.1*uy));
  
% Tangente
  
  path qqq;
  qqq=q rotatedaround(A,27);
  draw q rotatedaround(A,27) withpen pencircle scaled 1.5bp withcolor vert_e;
  
% Verticale
  pair B,BB;
  B:=A yscaled0; BB:=A xscaled 0;
  
  draw A--B dashed evenly;
  draw A--BB dashed evenly;
  
  draw (B shifted (0,.1*uy))--(B shifted (0,-.1*uy)); label.bot(btex $a$ etex,B shifted (0,-.17*uy));
  draw (BB shifted (.1*ux,0))--(BB shifted (-.1*ux,0)); label.lft(btex $f(a)$ etex,BB shifted (-.17*ux,0));
  
% Droite tournée
  path r;
  
  r:=q rotatedaround(A,38);
  
% Mh et sa verticale
  pair C;
  
  C:=(3.25*ux,2.4*uy);
  
  draw C withpen pencircle scaled 3.5bp;
  
  label.ulft(btex $M'$ etex,C shifted (-.1*ux,.1*uy));
  
  pair D,DD;
  
  D:=C yscaled0;
  DD:=C xscaled0;
  
  draw C--D dashed evenly;
  draw C--DD dashed evenly;
  
  draw (D shifted (0,.1*uy))--(D shifted (0,-.1*uy)); label.bot(btex $a+$d$x$ etex,D shifted (0,-.1*uy));
  draw (DD shifted (.1*ux,0))--(DD shifted (-.1*ux,0)); label.lft(btex $f(a+$d$x)$ etex,DD shifted (-.1*ux,0));
  
% La flèche
  
  pair E; % point de départ de la flèche
  pair F; % point d'arrivée de la flèche
  
  E=(3.5*ux,2.7*uy); F=E rotatedaround(A,-10);
  
% triangle caractéristique
  path pp,qq; pair G,AA,H,HH;
  AA:=A shifted(10*ux,0); 
  pp:=BB--AA;  qq:=C--D;
  G:=(pp intersectionpoint qq);
  H:=(qqq intersectionpoint qq);
  HH:=H shifted(10*ux,0);
  draw H withpen pencircle scaled 3.5bp;
  draw G withpen pencircle scaled 3.5bp;
  
  drawarrow G shifted(0.5*ux,0)--H shifted(0.5*ux,0) withcolor 0.6white;
  drawarrow A shifted(0,-0.2*uy)--G shifted(0,-0.2*uy) withcolor 0.6white;
  label.rt(btex d$f$ etex,((H+G)/2)shifted(0.5*ux,0)) withcolor 0.6white;
  label.bot(btex d$x$ etex,((A+G)/2)shifted(0,-0.3*uy))withcolor 0.6white;
  label.lrt(btex $T$ etex, (H shifted(0.1*ux,0))) withcolor 0.6white;
  label.lrt(btex $G$ etex, (G shifted(0.1*ux,0))) withcolor 0.6white;
  draw A--G shifted(0.95*ux,0) dashed evenly;
  draw H--H shifted(0.5*ux,0) dashed evenly;
  draw C--C shifted(0.95*ux,0) dashed evenly;
  drawarrow G shifted(0.95*ux,0)--C shifted(0.95*ux,0) withcolor 0.6white;
  label.rt(btex $\Delta f$ etex,((C+G)/2)shifted(0.95*ux,0)) withcolor 0.6white;
endfig;
end