# Tema 9
09-2  Integral d'una funció en un interval
          Càlcul d'integrals

## Càlcul de la integral definida

kill(all)$

f1(x):=3*x^2 - 2*x + 4$
'integrate(f1(x), x, 1, 3)=integrate(f1(x), x, 1, 3);

f2(x):=sin(omega*x)$
'integrate(f2(x), x, a, b)=integrate(f2(x), x, a, b);

f3(x):=exp(alpha*x)$
'integrate(f3(x), x, a, b)=integrate(f3(x), x, a, b);

f4(x):=cos(x)/(100 - x^6)$
'integrate(f4(x), x, 0, 1)=integrate(f4(x), x, 0, 1);

## Teorema del valor mitjà integral

kill(all)$

f(x):=cos(x)/(100 - x^6);

'integrate(f(x), x, 0, 1)=integrate(f(x), x, 0, 1);

wxplot2d([f(x)], [x,0, 1], [y, 0, 0.015], [ylabel, ""] , [legend, "f(x)"] , [style, [lines, 2]] ,
 [gnuplot_preamble, "set size ratio 1; set grid"] ,  [nticks, 300]    )$

M=M:f(0);           m=m:f(1);       
f(0), numer;        f(1), numer;

Integral_aproximada=IA:(m+M)/2;

%, numer;

IA(x):=0.0077287995245866$
wxplot2d([f(x), IA(x)], [x,0, 1], [y, 0, 0.015],  [legend, "f(x)" , "IA(x)"], [ylabel, ""] , [style, [lines, 2]] ,
 [gnuplot_preamble, "set size ratio 1; set grid"] ,  [nticks, 300]    )$

g(x):=(sin(x))^2$
'integrate(g(x), x, 0, 2*%pi)=integrate(g(x), x, 0, 2*%pi);

Vef=Vef:sqrt((1/(2*%pi))*integrate(g(x), x, 0, 2*%pi));

wxplot2d([g(x), Vef], [x, 0, 2*%pi], [y, 0, 1.5] , [legend, "g(x)" , "Vef"], [ylabel, ""] , [style, [lines, 2]] ,
 [gnuplot_preamble, "set size ratio 1; set grid"] ,  [nticks, 300]    )$