%@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);
% Déclarations des constantes %
numeric xmin, xmax, ymin, ymax, N;
ux:=0.4cm;
uy:=2cm;
xmin := -1; xmax := 20;
ymin := -.7; ymax := 1.5;
% 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
enddef;
vardef f(expr x) =1/sqrt(x)+0.125*x-1 enddef;
vardef tracee (suffix g)(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;
vardef fd(expr x) =0.125*x-1 enddef;
vardef traced (suffix gd)(expr a,b,inc) =
save i; numeric i;
for i=a step inc until b:
(i*ux,fd(i)*uy) ..
endfor (b*ux,fd(b)*uy)
enddef;
axes; label.llft(btex $0$ etex,(0,-.01*uy));
pair h,b,d,g; % shift des tirets
b:=(0,-.05*uy); h:=(0,.05*uy);
d:=(0.1*ux,0); g:=(-0.1*ux,0);
% Le deuxième point et l'écart
path p,T; pair D,E,F,ee, EO,FO;
p:=tracee(f,0.2,20,0.01);
draw p withpen pencircle scaled 2bp withcolor bleu_f;
D:=(14*ux,f(14)*uy);
T:= traced(fd,3,20,0.01); draw T dashed evenly withpen pencircle scaled 1.5bp withcolor 0.6white;
E:=D yscaled 0;
EO:=D xscaled 0;
path r,rr;
r:=D--E;
F:=(T intersectionpoint r);
FO:= F xscaled 0;
rr:=D--F;
ee:=(14*ux,f(14)*uy);
label.lrt(btex $\mathbf{e(x)}$ etex, ee)withcolor bleu_m;
drawarrow D--F withpen pencircle scaled 1.5bp withcolor bleu_m; drawarrow F--D withpen pencircle scaled 1.5bp withcolor bleu_m;
draw F--E dashed withdots withcolor bleu_m withpen pencircle scaled 1.5bp ;
draw F--FO dashed withdots withcolor bleu_m withpen pencircle scaled 1.5bp ;
draw D--EO dashed withdots withcolor bleu_m withpen pencircle scaled 1.5bp ;
label.lft(btex $f(x)$ etex,EO shifted g)withcolor bleu_m; draw (EO shifted g)--(EO shifted d)withcolor bleu_m;
label.lft(btex $ax+b$ etex,FO shifted g)withcolor bleu_m; draw (FO shifted g)--(FO shifted d)withcolor bleu_m;
label.bot(btex $x$ etex,E shifted b)withcolor bleu_m; draw (E shifted h)--(E shifted b)withcolor bleu_m;
label.ulft(btex $y=f(x)$ etex, (18*ux,f(18)*uy))withcolor bleu_f;
label.lrt(btex $y=ax+b$ etex, (18*ux,fd(18)*uy))withcolor 0.6white;
endfig;
end