/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/ /* [ Created with wxMaxima version 11.08.0 ] */ /* [wxMaxima: title start ] Using Riemann Sums to Estimate Areas, Volumes, and Lengths of Arc [wxMaxima: title end ] */ /* [wxMaxima: comment start ] Chapter 6 Technology Application Project [wxMaxima: comment end ] */ /* [wxMaxima: section start ] Introduction [wxMaxima: section end ] */ /* [wxMaxima: comment start ] OBJECTIVE: Use Riemann sums to approximate areas, volumes, and lengths of arc. Construct accumulation functions and see how the accumulated quantities converge on the antiderivative in the limit. In this module, we explore the use of Riemann sums to estimate areas, volumes of revolution, and the length of a curve. First, we write an expression for (delta Q[i]), where Q is the quantity of interest (area, volume, or arc length), we look at (delta Q[i])/(delta x) as the rate at which Q accumulates with respect to increments in x, we form a list of accumulated quantities, Q[i], and finally, we use the list of Q[i]'s to reconstruct (delta Q[i])/(delta x). We create three new procedures in this module areas( ), volumes( ), and lengths( ) to help you explore the use of Reimann Sums with areas, volumes and arc lengths. Make sure you execute the special code before running the rest of the worksheet. [wxMaxima: comment end ] */ /* [wxMaxima: subsect start ] Technology Guidelines [wxMaxima: subsect end ] */ /* [wxMaxima: comment start ] NOTE: If you have just finished a document, restart Maxima before executing a new document. This can be done by choosing "Restart" from the Maxima menu. TO OPEN OR CLOSE CELLS Click on the arrow at the top of the cell bracket. TO STOP AN EXECUTION Click on STOP button from the toolbar. ORDER OF EXECUTION Execute commands in the order given. Do not skip any Maxima Input lines within a given document. Alternatively, you can execute the entire worksheet by selecting the "Evaluate All Cells" command from the "Cell" drop down menu or simply press Ctrl-r. SAVING WORKSHEETS You can save anytime to any directory you choose, and it is wise to save often. EXPERIENCING MAJOR PROBLEMS Save if appropriate, and then shut down Maxima and start it up again. [wxMaxima: comment end ] */ /* [wxMaxima: subsect start ] Special Code [wxMaxima: subsect end ] */ /* [wxMaxima: comment start ] The code that follows defines the three special functions that are used in this worksheet. You do not have to understand the code to do this worksheet, however, you will need to execute it in order to define the special functions that are used later. You can execute the code by placing the cursor anywhere in the next input cell and then pressing Ctrl-Enter. After you execute the following code, proceed to Part I of the worksheet. [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ load(draw)$ numer: true$ simpsum: true$ ratprint: false$ fpprintprec: 8$ fpprec : 8$ /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ areas(a,b,n,fnc) := block( local(A, arealist,ratelist,Alist,m,deltaA,msecant, p0,p1,p2,p4,h,k,ff,aa,eqn,varlist,c1,c2,f,i,ii), h: (b-a)/n, deltaA(i) := subst((a+i*h)*h,x,fnc), print("(delta A[i]): ",deltaA(i)), ratelist: makelist([a+ii*h,deltaA(ii)/h],ii,0,n-1), print(""), print("(delta A[i])/(delta(x)): ",deltaA(i)/h), p0: points(ratelist), wxdraw2d( nticks=200, color=blue, p0, title="(delta A[i])/(delta x)", xlabel="x[i]"), A[total](k) := sum(deltaA(j),j,0,k-1), print(""), print("A[total](k): ",ratsimp(A[total](k))), arealist: makelist([a+k*h,A[total](k)],k,0,n), p1: points(arealist), wxdraw2d( nticks=200, color=red, point_type=6, p1, title="A[total](k)", xlabel="x[k]"), Alist: [makelist(arealist[c1][1],c1,1,length(arealist)), makelist(arealist[c2][2],c2,1,length(arealist))], A[approx](x) := expand(A[total]((x-a)/h)), print(""), print("A[approx](x): ",A[approx](x)), p2: explicit(A[approx](x),x,a,a+n*h), wxdraw2d( nticks=200, color=red, point_type=6, p1, color=blue, p2, title="A[approx](x) and A[total](k)", xlabel="x"), m[secant](i) := (A[total](i+1)-A[total](i))/h, print(""), print("m[secant](i): ",m[secant](i)), msecant: makelist([a+k*h, m[secant](k)],k,0,n-1), p4: points(msecant), wxdraw2d( nticks=200, color=red, point_type=6, p4, title="m[secant](i)", xlabel="x[i]"), wxdraw2d( nticks=200, color=red, point_type=6, p4, point_type=1, color=blue, p0, title="(delta A[i])/(delta x) and m[secant](i)", xlabel="x[i]"))$ /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ volumes(a,b,n,fnc) := block( local(volumesum, volumelist,ratelist,Vlist,V,m,deltaV,msecant, p0,p1,p2,p4,h,k,ff,aa,eqn,varlist,c1,c2,f,i,ii), h: (b-a)/n, deltaV(i) := %pi*subst((a+i*h),x,fnc)^2*h, print("(delta V[i]): ",deltaV(i)), ratelist: makelist([a+ii*h,deltaV(ii)/h],ii,0,n-1), kill(i), print(""), print("(delta V[i])/(delta(x)): ",deltaV(i)/h), p0: points(ratelist), wxdraw2d( nticks=200, color=blue, p0, title="(delta V[i])/(delta x)", xlabel="x[i]"), V[total](k) := sum(deltaV(j),j,0,k-1), print(""), print("V[total](k): ",ratsimp(V[total](k))), volumelist: makelist([a+k*h,V[total](k)],k,0,n), p1: points(volumelist), wxdraw2d( nticks=200, color=red, point_type=6, p1, title="V[total](k)", xlabel="x[k]"), Vlist: [makelist(volumelist[c1][1],c1,1,length(volumelist)), makelist(volumelist[c2][2],c2,1,length(volumelist))], V[approx](x) := expand(V[total]((x-a)/h)), print(""), print("V[approx](x): ",V[approx](x)), p2: explicit(V[approx](x),x,a,a+n*h), wxdraw2d( nticks=200, color=red, point_type=6, p1, color=blue, p2, title="V[approx](x) and V[total](k)", xlabel="x"), m[secant](i) := (V[total](i+1)-V[total](i))/h, print(""), print("m[secant](i): ",m[secant](i)), msecant: makelist([a+k*h, m[secant](k)],k,0,n-1), p4: points(msecant), wxdraw2d( nticks=200, color=red, point_type=6, p4, title="m[secant](i)", xlabel="x[i]"), wxdraw2d( nticks=200, color=red, point_type=6, p4, point_type=1, color=blue, p0, title="(delta V[i])/(delta x) and m[secant](i)", xlabel="x[i]"))$ /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ lengths(a,b,n,fnc) := block( local(lengthsum, lengthlist,ratelist,Llist,L,m,deltaL,msecant, p0,p1,p2,p4,h,k,ff,aa,eqn,varlist,c1,c2,f,i,ii), h: (b-a)/n, deltaL(i) := sqrt(1+((subst(a+i*h+h,x,fnc)-subst(a+i*h,x,fnc))/h)^2)*h, print("(delta L[i]): ",deltaL(i)), ratelist: makelist([a+ii*h,deltaL(ii)/h],ii,0,n-1), kill(i), print(""), print("(delta L[i])/(delta(x)): ",deltaL(i)/h), p0: points(ratelist), wxdraw2d( nticks=200, color=blue, p0, title="(delta L[i])/(delta x)", xlabel="x[i]"), L[total](k) := sum(deltaL(j),j,0,k-1), print(""), print("L[total](k): ",ratsimp(L[total](k))), lengthlist: makelist([a+k*h,L[total](k)],k,0,n), p1: points(volumelist), wxdraw2d( nticks=200, color=red, point_type=6, p1, title="L[total](k)", xlabel="x[k]"), Llist: [makelist(lengthlist[c1][1],c1,1,length(lengthlist)), makelist(lengthlist[c2][2],c2,1,length(lengthlist))], L[approx](x) := expand(L[total]((x-a)/h)), print(""), print("L[approx](x): ",L[approx](x)), p2: explicit(L[approx](x),x,a,a+n*h), wxdraw2d( nticks=200, color=red, point_type=6, p1, color=blue, p2, title="L[approx](x) and L[total](k)", xlabel="x"), m[secant](i) := (L[total](i+1)-L[total](i))/h, print(""), print("m[secant](i): ",m[secant](i)), msecant: makelist([a+k*h, m[secant](k)],k,0,n-1), p4: points(msecant), wxdraw2d( nticks=200, color=red, point_type=6, p4, title="m[secant](i)", xlabel="x[i]"), wxdraw2d( nticks=200, color=red, point_type=6, p4, point_type=1, color=blue, p0, title="(delta L[i])/(delta x) and m[secant](i)", xlabel="x[i]"))$ /* [wxMaxima: input end ] */ /* [wxMaxima: section start ] Part I: Areas [wxMaxima: section end ] */ /* [wxMaxima: comment start ] Sections 5.3 and 5.4 [wxMaxima: comment end ] */ /* [wxMaxima: comment start ] C:\Documents and Settings\srzollinger.WA-ZOLLINGER-O1\My Documents\My Pictures\Ch6_avl6.jpg [wxMaxima: comment end ] */ /* [wxMaxima: comment start ] Note: In this exercise, delta A[i] represents the area of the ith rectangle, as shown in the figure above. In this Part, we will do the following: 1. Form a function, delta A[i], that gives the area of the ith rectangle in terms of f(x[i]) and h. 2. Form a rate of change function, (delta A[i])/(delta x), that gives the rate of accumulation of area at x[i] = a + ih, for i = 0, 2, 3, . . ., n-1 , where n is the number of rectangles between x = a and x = b. 3. Form a function, A[total](k), that gives the sum of the areas of the rectangles, that is, the (delta A[i])'s, as i ranges from 0 to k. This approximates the area under the graph of y = f(x), between x = a and x = a + kh, for k = 0, 2, 3, . . ., n , where n is the number of rectangles between x = a and x = b. 4. Form a function that gives the slopes of the secant lines on the graph of the A[total](k) function found in step 3, and shows that this is the same as the rate of change function found in step 2. Our first objective is to write delta A[i], the area of the ith rectangle, in terms of f(x[i]) and h where x[i] = a + ih. At first, we let a = -5, b = 10, and n = 10. [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ f(x) := x$ a: -5$ b: 10$ n: 10$ h: (b-a)/n$ deltaA(i) := f(a+i*h)*h$ print("delta A[i]: ",deltaA(i))$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] You should note that if f(x[i]) is negative and delta x is positive, then delta A[i] is negative. The areas can be positive, negative, or zero, and so we refer to them as "signed areas". Areas above the x-axis are positive and areas below the x-axis are negative, provided delta x = h is positive. Next we form the rate-of-change function, (delta a{i])/(delta x). The function (delta a{i])/(delta x) is the rate at which the total signed area of the rectangles accumulates with each increment of delta x = h that is added to x. We generate a list of the rate-of-change values for each x[i] = a + ih, and plot the rate-of-change versus x[i], assigning the graph to the symbol name p0 for later reference. [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ print("rate of acumulation of area function (delta A[i])/(delta x): ")$ print(deltaA(i)/h)$ print("")$ ratelist: makelist([i,a+i*h,(deltaA(i))/h], i, 0, n-1)$ m1: matrix(["i", "x[i]=a+i*h", "(delta A[i])/(delta x)"])$ for i: 1 thru length(ratelist) do block( m1: addrow(m1, ratelist[i]))$ m1; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ p0: points(ratelist)$ wxdraw2d( nticks=200, color=blue, point_type=6, p0, title="(delta A[i])/(delta x)", xlabel="x[i]"); /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] You have probably noticed that, for the area problem, the rate at which the total area of the rectangles accumulates with each added increment h in x is simply f(x[i]), the height of the ith rectangle. That is,(delta A[i])/(delta x) = f(x[i]). Now we form a function that calculates the left Riemann sum of the delta A[i]'s for the first k rectangles, where k can range between 0 and n. [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ A[total](k) := sum(deltaA(i),i,0,k-1)$ print("A[total](k): ", A[total](k))$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] For example, we can use A[total](4) to calculate the total signed area of the first 4 rectangles. [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ A[total](4); /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] Or, we can calculate the area of all 10 rectangles. (Recall that we set n = 10.) [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ A[total](10); /* [wxMaxima: input end ] */ /* Maxima can't load/batch files which end with a comment! */ "Created with wxMaxima"$