input newcourbes;
input couleur;
input geometriesyr16;
input TEX;


verbatimtex
%&latex
\documentclass{article}
\usepackage[upright]{fourier}
\usepackage{color}
\def\E{\mathrm{e}}
\let\ve\vec
\def\DR{\mathcal{D}}
\def\CR{\mathcal{C}}
\newcommand{\Mathbold}[1]{\mbox{\boldmath$#1$\unboldmath}}
\begin{document}
etex

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% réciproque
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



beginfig(1)
  

  
vardef fx(expr t)= t enddef;
vardef fy(expr t)= exp(t-1)-t enddef;

repere(0,0,-1,4,-3,4,2cm,2cm);
r_axes;
r_origine;
r_unites;
r_labelxy;

path g,h;
g:= f_courbe(fx,fy,1,4,100);
draw g withcolor red;
draw g reflectedabout ((0,0),r_p(3,3)) withcolor blue;
draw r_droite(0,0,1) dashed evenly;

pair n;
n:=r_p(2,fy(2));
label.lrt(btex $y=f(x)=\E^{x-1}-x$ etex,n ) withcolor red;
label.lrt(btex $y=f^{-1}(x)$ etex,n reflectedabout ((0,0),r_p(3,3)) ) withcolor blue;
label.lrt(btex $y=x$ etex, r_p(-2,-2));
r_fin;
endfig;


%%%%%
% approximation discrète d'une edo
%%%%%%%%%%%%%%%%%%%%%%%%






beginfig(2)

repere(0,0,-1,10,-1,5,1cm,1cm);
r_axenom(btex $t$ etex,btex $u$ etex);
r_origine;


vardef fx(expr t)=t   enddef;
vardef fy(expr t)=sqrt(t+1)   enddef;

draw f_courbe(fx,fy,0,8,100) withpen pencircle scaled 1.3bp withcolor .6white;

numeric v;
pair uz, uu, ud, ut,Uu,Ud,Ut,Uq,tu,td,tt;
uz:=r_p(0,fy(0));r_pp(0,fy(0));
uu:=r_p(2,fy(2));tu:=r_p(2,0);
ud:=r_p(4,fy(4));td:=r_p(4,0);
ut:=r_p(6,fy(6));tt:=r_p(6,0);
v:=1;
Uu:=r_p(2,fy(2)+.7v);r_pp(2,fy(2)+.7v);
Ud:=r_p(4,fy(4)+v);r_pp(4,fy(4)+v);
Ut:=r_p(6,fy(6)+v);r_pp(6,fy(6)+v);
Uq:=r_p(8,fy(8)+.9v);r_pp(7.5,fy(7.5)+.9v);

draw Uu--tu dashed evenly;
draw Ud--td dashed evenly;
draw Ut--tt dashed evenly;

r_cp(2,fy(2));r_cp(4,fy(4));r_cp(6,fy(6));

draw uz--Uu--Ud--Ut--Uq;
draw (Uu shifted r_p(.1v,.3v))--(Ud shifted r_p(-0.2v,.18v)) dashed withdots withpen pencircle scaled 2bp;
draw (tu shifted r_p(0.1v,-.3v))--(td shifted r_p(-0.1v,-.3v)) dashed withdots withpen pencircle scaled 2bp;




drawdblarrow (td shifted r_p(0,-v))--(tt shifted r_p(0,-v));


label.lrt(btex $u(t_n)$ etex, ud);
label.lrt(btex $u(t_{n+1})$ etex, ut);
label.top(btex $u_n$ etex, Ud);
label.top(btex $u_{n+1}$ etex, Ut);
label.ulft(btex $u_1$ etex, Uu);
label.lft(btex $u_0$ etex, uz);
label.lrt(btex $t_n$ etex, td);
label.llft(btex $t_1$ etex, tu);
label.bot(btex $t_{n+1}$ etex, tt);
label.top(btex $h$ etex, .5(td+tt) shifted r_p(0,-v));
label.top(btex {\small Solution numérique} etex, Uq);
label.top(btex {\small Solution exacte} etex, r_p(8,fy(8))) withcolor 0.6white;



r_fin;

endfig;




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%        M E T H O D E        D e S       T R A P E Z E S 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 $u$ etex,(0,ymax*uy)); % label de l'axe des y
  enddef;

 
beginfig(3);

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 $kh$ etex,m shifted -1.9h-d);
label.bot(btex $(k+1)h$ 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 $u(kh)=u_k$ etex,T shifted -d);
draw (TT shifted d)--(TT shifted -d); label.lft(btex $u((k+1)h)=u_{k+1}$ etex,TT shifted -d);


endfig;






%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%
%      Méthode de Newton
%
%









beginfig( 4)


%%%%%%%%%%%%%%%%%%%%%%%
vardef fx(expr t)=
t
enddef;

vardef fy(expr t)=
                          (t-1)**2    % c'est la seule ligne à changer
enddef;
%%%%%%%%%%%%%%%%%%%%%
repere(0,0,-.5,4,-2,5,3cm,1cm);
r_axes;

draw f_courbe(fx,fy,-.5,4,100)withpen pencircle scaled 1.5bp withcolor blue;
draw f_tangente(fx,fy,2,0.05);

dotlabel.top( btex  etex, r_p(2,1) );
dotlabel.top( btex  etex, r_p(2,0) );
dotlabel.top( btex  etex, r_p(1.5,0) );
dotlabel.top( btex  etex, r_p(1,0) );
draw r_segment(2,1,2,0) dashed evenly;

drawarrow r_p(1.5,-1.5)--r_p(1.5,-0.2) withcolor .7white;

drawarrow r_p(2,-1)--r_p(2,-0.1) withcolor .7white;

drawarrow r_p(.5,1)--r_p(1,0.1) withcolor .7white;

label.bot(btex $x_1$ etex,r_p(1.5,-1.5) )withcolor .7white;
label.bot(btex $x_0$ etex,r_p(2,-1) )withcolor .7white;
label.top(btex Le zéro cherché  etex,r_p(.5,1) )withcolor .7white;
r_fin;
endfig;

end