// préambule asymptote
usepackage("amsmath,amssymb");
usepackage("inputenc","utf8");
usepackage("icomma");

import lib_jl;

unitsize(1cm,1cm);

real xmin=-5.5, ymin=-1.5, xmax=5.5, ymax=5.5;

xlimits(xmin,xmax);
ylimits(ymin,ymax);

xaxis(BottomTop,xmin=xmin,xmax=xmax,Ticks("%",extend=true,Step=1),p=linewidth(0.5pt)+gray(0)+dotted);
yaxis(LeftRight,ymin=ymin,ymax=ymax,Ticks("%",extend=true,Step=1),p=linewidth(0.5pt)+gray(0)+dotted);

real F(real x) {return .5*(x+5)*(.5x^2+.25x+.5);}

draw(graph(F,-6,4,n=400),linewidth(1pt)+deepred+solid);

xlimits(xmin,xmax,Crop);
ylimits(ymin,ymax,Crop);

xaxis(axis=YEquals(0),xmin=xmin,xmax=xmax,Ticks("%",beginlabel=true,endlabel=true,begin=true,end=true,NoZero,Step=1,Size=1mm),p=linewidth(1pt)+black,Arrow(2mm),true);
yaxis(axis=XEquals(0),ymin=ymin,ymax=ymax,Ticks("%",beginlabel=true,endlabel=true,begin=true,end=true,NoZero,Step=1,Size=1mm),p=linewidth(1pt)+black,Arrow(2mm),true);

pair O=(0,0), I=(1,0), J=(0,1), A=(-4,0), B=(1,0), C=(-1.5,0);

labelx(Label("$O$",NoFill), 0, SW);
label("$I$",I,SE);
label("$J$",J,NW);

draw(line(A-(0,2),A+(0,2)),deepblue+pen1);
label("$a$",A,SE,deepblue);

path integrale1=buildcycle((A.x, F(A.x))--A--C--(C.x, F(C.x)),graph(F,A.x,C.x));
add("integrale1",hatch(H=.5mm,dir=NE,lightred));
fill(integrale1,pattern("integrale1"));

label(scale(.9)*"$\int_{a}^{c} f(x)\; dx$",((A.x+C.x)/2,2),deepred);

path integrale2=buildcycle((C.x, F(C.x))--C--B--(B.x, F(B.x)),graph(F,C.x,B.x));
add("integrale2",hatch(H=.5mm,dir=NW,lightgreen));
fill(integrale2,pattern("integrale2"));

label(scale(.9)*"$\int_{c}^{b} f(x)\; dx$",((C.x+B.x)/2,.5),deepgreen);

draw(line(B-(0,2),B+(0,2)),deepblue+pen1);
label("$b$",B,SW,deepblue);

draw(line(C-(0,2),C+(0,2)),deepgreen+pen1);
label("$c$",C,SW,deepgreen);

shipout(bbox(0.1cm,0.1cm,white));

