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


%METHODE DeS TRAPEZES

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

ux:=1cm;  uy:=1cm;
xmin := -.5 ; xmax := 8;
ymin := -.5; ymax := 4;

pair d,h;
d:=(.1*ux,0);
h:=(0,.1*uy);

% 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.rt(btex $t$ etex,(xmax*ux,0)); % label de l'axe des x
  label.urt(btex $x$ etex,(0,ymax*uy)); % label de l'axe des y
enddef;


beginfig(1);
  path t; % tirets
  t:=((0,0)shifted h)--((0,0)shifted -h);
  
  pair A,B,C,a,b;
  A=(ux,1.5*uy);
  C=(2.5*ux,2.5*uy);
  B=(7*ux,uy);
  a=A yscaled 0;
  b=B yscaled 0;
  
  pair M,N,m,n; path P,Q,QQ,R,S;
  
  P=A{dir-10}..C..{dir-10}B;
  
  M=point .7 of P;
  N=point 1.2 of P;
  m=M yscaled 0;
  n=N yscaled 0;
  
  S=subpath(.7,1.2) of P; 
  QQ=M--N;
  Q=N--n--m--M--cycle; 
  R=buildcycle(S,QQ);
  
  fill R withcolor bleu_f;
  
  fill Q withcolor bleu;
  
  axes;
  draw P;
  draw (A--a) dashed evenly;
  draw (B--b) dashed evenly;
  draw (M--m) dashed evenly;
  draw (N--n) dashed evenly;
  
  draw t shifted a;
  draw t shifted b;
  draw t shifted m;
  draw t shifted n;
    
  label.bot(btex $kT_e$ etex,m shifted -1.9h-d);
  label.bot(btex $(k+1)T_e$ etex,n shifted -h+4d);
  
  pair T;
  T=M xscaled 0;
  draw (T--M) dashed evenly;
  pair TT;
  TT=N xscaled 0;
  draw (TT--N) dashed evenly;
  
  path U,V; pair t;
  U=N--n;
  V=T--(T shifted (6*ux,0));
  t=U intersectionpoint V;
    
  draw (T shifted d)--(T shifted -d); label.lft(btex $x(kT_e)=x_k$ etex,T shifted -d);
  draw (TT shifted d)--(TT shifted -d); label.lft(btex $x((k+1)T_e)=x_{k+1}$ etex,TT shifted -d);
endfig;
end