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

% approximation affine

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

ux:=1cm;
uy:=0.9cm;
xmin := 1.1; xmax := 7;
ymin := -.3; ymax := 4;

% 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)) shifted (1.4*ux,0) ; % axe des y
enddef;


beginfig(1);

  axes; label.llft(btex $0$ etex,(1.3*ux,-.1*uy));
  
  pair h,b; % shift des tirets
  
  b:=(0,-.1*uy); h:=(0,.1*uy);
  
% Courbe
  path p;
  p:=(1.6ux,1.2*uy)..(2.5*ux,uy)..(5.5*ux,4*uy);

  draw p withpen pencircle scaled 1.3bp withcolor bleu_m; label.rt(btex $\mathcal{C}_f$ etex,(5.5*ux,4*uy)shifted 2h);

% Tangente
  numeric e; %paramètre du point A
  pair M,A;
  
  e:=1.3;
  
  A:=point e of p; M:=direction e of p;
  
  path T; T:=(A shifted -1.5M)--(A shifted 1.5M); draw T withcolor bleu; label.rt(btex $\mathcal{T}$ etex,A shifted M+(.7*ux,0)+4h) withcolor bleu;
  
% Verticales
  draw A withpen pencircle scaled 3bp withcolor bleu_m; label.top(btex $A$ etex, A shifted h)withcolor bleu_m;
  
  pair B; B:= A yscaled 0;
  
  draw A--B dashed evenly withcolor 0.6white; label.bot(btex $a$ etex,B shifted b) withcolor 0.6white;
  
  draw (B shifted b)--(B shifted h) withcolor 0.6white;
  
% Le deuxième point et l'écart
  pair D,E,F; D:=point 1.7 of p;
  
  E:=D yscaled 0;
  
  path r;
  
  r:=D--E;
  
  F:=(T intersectionpoint r);
  
  drawarrow D--F withpen pencircle scaled 1.5bp withcolor 0.6white; drawarrow F--D withpen pencircle scaled 1.5bp withcolor 0.6white; label.rt(btex $e(x)$ etex,(4*ux,3.4*uy)) withcolor 0.6white;
  draw F--E dashed evenly withcolor 0.6white;
  
  label.bot(btex $x$ etex,E shifted b)withcolor 0.6white; draw (E shifted h)--(E shifted b) withcolor bleu_f;

% La flèche

  pair G; % point de départ de la flèche
  pair H; % point d'arrivée de la flèche
  
  G=(4.7*ux,3.1*uy); H=G rotated -10;
  
  drawarrow G{dir(250+angle (G))}..{dir(-20-angle (H))}H withcolor 0.6white;
  
endfig;
end