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