Maple Code for Optional Problems in Chapter 11

This file can be loaded into Maple (imported as text) and then executed.

Section 11.1 Problem 11

 
> N:=64; #other values of N can be used as well. Allow lots of time for
> N=256

                               N := 64

> delx:=1/N; dely:=1/N;  #the x and y - step sizes for the grid

                             delx := 1/64


                             dely := 1/64

> f:=(x,y) ->exp(-x^2-y^2);

                                          2    2
                     f := (x, y) -> exp(-x  - y )

> S:=Sum(Sum(f(j*delx+delx/2, k*delx
> +delx/2),k=0..N-1),j=0..N-1)*delx*dely;

S := 1/4096

    / 63   / 63                                              \\
    |----- |-----                                            ||
    | \    | \                         2                   2 ||
    |  )   |  )   exp(-(1/64 j + 1/128)  - (1/64 k + 1/128) )||
    | /    | /                                               ||
    |----- |-----                                            ||
    \j = 0 \k = 0                                            //

> evalf(");

                             .5577574648

Section 11.3 , Problem 52

 
> f:=1-x-y; g:=4-x^2-y^2;  # Define the two given functions

                            f := 1 - x - y


                                     2    2
                           g := 4 - x  - y

> p1:=plot3d(f,x=-2..3,y=-2..3): #Assign the plot of f to a variable p1
> p2:=plot3d(g,x=-2..3,y=-2..3): #Assign the plot of g to a variable p2
> with(plots):
> display({p1,p2});  # This command will plot both f and g on the same
> axes.
> eq:=f=g; #Set up the equation to find the curve corresponding to f=g

                                           2    2
                    eq := 1 - x - y = 4 - x  - y

> sol:=solve(eq,y); #Solve this equation for y in terms of x

                          2       1/2                     2       1/2
sol := 1/2 + 1/2 (13 - 4 x  + 4 x)   , 1/2 - 1/2 (13 - 4 x  + 4 x)

# The solution has two branches corresponding to the top
# and bottom half of the circle. 
# To set up the integral, we need to find the x-values corresponding to 
# where these two brances meet (the left and right points on the
# circle).
> a:=solve(sol[1]=sol[2],x);

                                 1/2              1/2
                a := 1/2 + 1/2 14   , 1/2 - 1/2 14

# Now set up the integral. Note that g>f
> integ:=Int(Int(g-f,y=sol[2]..sol[1]),x=a[2]..a[1]);

                        1/2
            1/2 + 1/2 14
           /
          |
integ :=  |
          |
         /
                       1/2
           1/2 - 1/2 14

                          2       1/2
       1/2 + 1/2 (13 - 4 x  + 4 x)
      /
     |                                     2    2
     |                                3 - x  - y  + x + y dy dx
     |
    /
                         2       1/2
      1/2 - 1/2 (13 - 4 x  + 4 x)

> evalf("); #Give this a few minutes to calculate

                             19.24225500


>