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);

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

> simpson(f(x), x = a..b, n);

[Maple Math]
[Maple Math]

Application of simpson rule to several functions.

> f1:= x-> sin(x):

> intf1:= subs({a = 0, b = Pi}, simpson(f1(x), x = a..b, 10));

[Maple Math]
[Maple Math]

> evalf(%);

[Maple Math]

> int(f1(x), x = 0..Pi);

[Maple Math]

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(%);

[Maple Math]

> int(f2(x), x = 0..1.5);

[Maple Math]

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(%);

[Maple Math]

> int(x*f3(x), x = 0..2.45);

[Maple Math]

Integration of error function.

> f4:= x-> erfc(x):

> intf4:= subs({a = 0, b = 2.75}, simpson(f4(x), x = a..b, 40)):

> evalf(%);

[Maple Math]

> int(f4(x), x = 0..2.75); evalf(%);

[Maple Math]

[Maple Math]

>