Approximating Areas / Integrals

Some key commands are:

 leftbox rightbox middlebox leftsum rightsum middlesum trapezoid simpson value evalf

NOTE: First you must load the necessary commands by entering:

> with(student);

I. Graphing Regions & Rectangles

Example: Suppose we want to graph the region bound between the function

f (x) = 4 - x2,

the x-axis, and the vertical lines x= -1, x=2, and show rectangles.

> f:= 4 - x^2;  defines function f as an expression

> rightbox(f,x=-1..2,6);  plots f showing 6 right-ended rectangles

> leftbox(f,x=-1..2,12);  plots f showing 12 left-ended rectangles

> middlebox(f,x=-1..2,10);  plots f showing 10 midpoint rectangles

II. Approximating Areas of Regions Using Rectangles

Example: Suppose we want to approximate the area of the region bound between the function

f (x) = 4 - x2,

the x-axis, and the vertical lines x= -1 and x=2.

> f:=4-x^2;  defines function f as an expression

> R:= rightsum(f,x=-1..2,6);  using 6 right-ended rectangles

> value(R);  numerical value of the result R

> evalf(R);  decimal value of the result R

> L:= leftsum(f,x=-1..2,12);  using 12 left-ended rectangles

> value(L);  numerical value of the result L

> evalf(L);  decimal value of the result L

> M:= middlesum(f,x=-1..2,10);  using 10 midpoint rectangles

> evalf(M);  decimal value of the result M

III. Approximating Areas / Integrals Using the Trapezoidal Rule

Example: Suppose we want to approximate the area of the region bound between the function

f (x) = e-x2,

the x-axis, and the vertical lines x= -1 and x=2.

> f:=exp(-x^2);  defines function f as an expression

> T:= trapezoid(f,x=-1..2,6);  using 6 subintervals

> evalf(T);  decimal value of the result T

IV. Approximating Areas / Integrals Using Simpson's (1/3) Rule

Note: The number of subintervals must be even.

Example: Suppose we want to approximate the area of the region bound between the function

f (x) = e-x2,

the x-axis, and the vertical lines x= -1 and x=2.

> f:=exp(-x^2);  defines function f as an expression

> S:= simpson(f,x=-1..2,6);  using 6 subintervals

> evalf(S);  decimal value of the result S

V. Exact Areas Using Limits

Example: Determine the exact area of the region bound between the function

f (x) = 4 - x2,

the x-axis, and the vertical lines x= -1 and x=2.

> n:='n';  resets n in case it was previously assigned a value

> f:=4-x^2;  defines function f as an expression

> approx:=rightsum(f,x=-1..2,n);  uses n right-sided rectangles

> simp:= value(approx);  simplifies the sums and calls result simp

> area:=limit(simp,n=infinity);  lets the number of rectangles go to infinity

NOTE: For many other commands common to student use, enter

> ?student;