ClearAll["Global`*"];
(*(e x+f)(a x-b)(c x-d)*)
ri [m_, n_] := Module[{v}, v= RandomInteger[{m, n}]; If[v==0, 1, v]];
rv="??";
s={};
f1=0;
f2=0;
 
rv="?";
 
genfunc:=Module[{}, {a, b, c, d, e, f, g, h, i, j} ={ri[-3, 3], ri[-9, 9],ri[-3, 3],ri[-9, 9],ri[-3, 3],ri[-9, 9],ri[-3, 3],ri[-9, 9],ri[-3, 3], ri[0, 2]};
If[RandomReal[]<1, {e, a, c}={1, 1, 1}];
If[RandomReal[]<0.5, {e, f}={0, 1}];
f1 =b d f+b d e x-b c f x-a d f x-b c e (x^2);
f2 =a d e (x^2)-a c f (x^2)-a c e (x^3);
grafico ="";
Return[];
];

genfunc;
grafico ="";
Manipulate[
Dynamic@Button[ 
s=x/.Solve[f1==f2, x];
s =Sort[s];
{min, max}:={s[[1]], s[[-1]]};
dist = max-min;
area=Dynamic[(∫_min^max)Abs[f1-f2]\[DifferentialD]x];
g1 =Dynamic@Plot[{f1, f2}, {x, min-0.1 ,  max+0.1}, Filling->{1->{2}}];
g2=Dynamic@ListPlot[Table[{s[[i]], f1/. x-> s[[i]]}, {i, Length[s]}]];
g=Dynamic@Show[g1, g2];
grafico =g;
 
r = Dynamic[(∫_min^max)Abs[f1-f2]\[DifferentialD]x];
rv="??";
grafico=Null;

"f(x)="<>ToString[TraditionalForm[MatrixForm[f1]]]<>", g(x) ="<> ToString[TraditionalForm[MatrixForm[f2]]]
, Appearance->"Frameless" ],
Dynamic@Button["Nuevo ejercicio",genfunc ], FrameLabel->Style["Calcule el área encerrada entre f y g"]
]
 Manipulate[Dynamic@Button[rv, "" ,  Appearance->"Frameless"],
Dynamic@Button["Ver respuesta", rv=r; grafico =g1],
Dynamic@Button[grafico,"",Appearance->"Frameless" ]

]

Autores: Juan Félix Ávila Herrera y Enrique Vílchez Quesada, Escuela de Informática, Universidad Nacional de Costa Rica,  .