Maple Tutorial 10:
Trapezoidal Rule
M.M. Yovanovich
TUTORIAL10.MWS
Trapezoidal Rule for approximate numerical integration of functions.
Use the Maple package student.
> restart:
> with(student);
> trapezoid(f(x), x = a..b, n);
Application of trapezoidal rule to several functions.
> f1:= x-> sin(x):
> intf1:= subs({a = 0, b = Pi}, trapezoid(f1(x), x = a..b, 20));
> evalf(%);
> int(f1(x), x = 0..Pi);
20 panels gives acceptable accuracy.
> f2:= x-> exp(-x)*cos(x)^1/2:
> intf2:= subs({a = 0, b = 1.5}, trapezoid(f2(x), x = a..b, 100)):
> evalf(%);
> int(f2(x), x = 0..1.5);
100 panels gives acceptable accuracy.
Integration of Bessel functions.
> f3:= x-> BesselJ(0,x):
> intf3:= subs({a = 0, b = 2.45}, trapezoid(x*f3(x), x = a..b, 40)):
> evalf(%);
> int(x*f3(x), x = 0..2.45);
Integration of error function.
> f4:= x-> erfc(x):
> intf4:= subs({a = 0, b = 2.75}, trapezoid(f4(x), x = a..b, 80)):
> evalf(%);
> int(f4(x), x = 0..2.75); evalf(%);
>