Approximate IntegrationName: Approximation methods for integrals are necessary since not all functions have antiderivatives. Three methods will be investigated: the Midpoint Rule, the Trapezoidal Rule, and Simpson's Rule.
<Text-field layout="Heading 1" style="Heading 1">The Midpoint Rule</Text-field>An interval a < x < b is divided into n subintervals, each of length NiMvKiYlJkRlbHRhRyIiIiUieEdGJiomLCYlImJHRiYlImFHISIiRiYlIm5HRiw= . Rectangles are drawn with a base of length NiMqJiUmRGVsdGFHIiIiJSJ4R0Yl and height the function value taken at the midpoint of the interval. To obtain better estimates, the number of rectangles can be increased.Example 1: Use the sum function to find the midpoint approximation to NiMtJSRpbnRHNiQtJSRleHBHNiMsJCokJSJ4RyIiIyEiIi9GKzsiIiEiIiI= with n = 10.f:=x->exp(-x^2);s:=sum(1/10*f(.5*(i/10+(i+1)/10)),i=0..9);The answer can be confirmed and a plot drawn using commands contained in the student package.with(student):middlebox(f(x),x=0..1,10);evalf(middlesum(f(x),x=0..1,10));Compare the result with what is given by the int command.int(f(x),x=0..1);evalf(%);
<Text-field layout="Heading 1" style="Heading 1">The Trapezoidal Rule</Text-field>The length of each subinterval is found as above, but instead of rectangles, trapezoids are inscribed in each subinterval. The following sequence of commands will plot a curve and the inscribed trapezoids.The formula for the area of a trapezoid is NiMvJSJBRyoqIiIiRiYlImhHRiYsJiUiYUdGJiUiYkdGJkYmIiIjISIi where h is the height and a and b are the two bases. In this case, NiMvJSJoRyomLCYlImJHIiIiJSJhRyEiIkYoJSJuR0Yq and a and b are the values of the function, evaluated at the two endpoints of each interval.The trapezoidal approximation is then given by:restart;with(plots):with(student): Input the function, change it to any one you wishf:=x->sqrt(x): Input the limits of integration of your choicea:=0:b:=6: The next statement will plot the function in the display command belowp:=plot(f(x),x=a..b,thickness=3,color=black): Choose the number of subintervalsn:=6: This statement creates an array for the trapezoidsc:=array(0..n): The for do loop creates the trapezoids with random colorsfor i from 0 to n-1 do c[i]:=polygonplot([[a+i*(b-a)/n,0],[a+(i+1)*(b-a)/n,0],[a+(i+1)*(b-a)/n,f(a+(i+1)*(b-a)/n)],[a+i*(b-a)/n,f(a+i*(b-a)/n)]],color=COLOR(RGB,rand()/10^12,rand()/10^12,rand()/10^12)):od: This command displays the function and the inscribed trapezoidsdisplay({seq(c[i],i=0..n-1),p});Example 2: Use the sum command to find the trapezoidal approximation to NiMtJSRpbnRHNiQtJSRleHBHNiMsJCokJSJ4RyIiIyEiIi9GKzsiIiEiIiI= with n = 20, compare it with the result given by the trapezoid and the int commands.restart;with(student):f:=x->exp(-x^2):s:=sum((1/20)/2*(f(i/20)+f((i+1)/20)),i=0..19);evalf(%);trapezoid(f(x),x=0..1,20);evalf(%);int(f(x),x=0..1);evalf(%);
<Text-field layout="Heading 1" style="Heading 1">Simpson' Rule</Text-field>Simpson's Rule is based on the use of parabolas to approximate a curve. If n (where n is even) subintervals are used for a given function NiMtJSJmRzYjJSJ4Rw== in the interval a < x < b and NiMvKiYlJkRlbHRhRyIiIiUieEdGJiomLCYlImJHRiYlImFHISIiRiYlIm5HRiw= , the formula to approximate the integral is as follows:Example 3: Use Simpson's Rule to approximate NiMtJSRpbnRHNiQtJSRleHBHNiMsJCokJSJ4RyIiIyEiIi9GKzsiIiEiIiI= with n = 20 and compare the result with those given by the midpoint command, the trapezoid command, and the int command.restart;with(student):f:=x->exp(-x^2):simpson(f(x),x=0..1,20);evalf(%);evalf(trapezoid(f(x),x=0..1,20));evalf(middlesum(f(x),x=0..1,20));evalf(int(f(x),x=0..1));
<Text-field layout="Heading 1" style="Heading 1">Exercises</Text-field>
<Text-field layout="Heading 1" style="Heading 1"><Font executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" style="_cstyle297" underline="false">Exercise 1: Use the </Font><Font bold="true" executable="false" family="Times New Roman" italic="false" style="_cstyle308" underline="false">sum</Font><Font executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" style="_cstyle309" underline="false"> command to approximate </Font><Equation input-equation="int(1/sqrt(1+x^3),x = 0 .. 3);" style="_cstyle256">NiMtJSRpbnRHNiQqJiIiIkYnLSUlc3FydEc2IywmRidGJyokJSJ4RyIiJEYnISIiL0YtOyIiIUYu</Equation><Font executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" size="18" style="_cstyle299" underline="false"> </Font><Font executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" style="_cstyle298" underline="false">with n = 20 using the midpoint rule. Confirm your answer using the </Font><Font bold="true" executable="false" family="Times New Roman" italic="false" style="_cstyle322" underline="false">middlesum</Font><Font executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" style="_cstyle323" underline="false"> command and graph the curve and the rectangles. Then compare it with the result given by the </Font><Font bold="true" executable="false" family="Times New Roman" italic="false" style="_cstyle324" underline="false">int</Font><Font executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" style="_cstyle325" underline="false"> command.</Font></Text-field>restart;with(student):
<Text-field layout="Normal" style="Normal"><Font bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" style="_cstyle295" underline="false">Exercise 2: Use the </Font><Font executable="false" family="Times New Roman" italic="false" style="_cstyle310" underline="false">sum</Font><Font bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" style="_cstyle311" underline="false"> command to approximate </Font><Equation input-equation="int(1/sqrt(1+x^3),x = 0 .. 3);" style="_cstyle256">NiMtJSRpbnRHNiQqJiIiIkYnLSUlc3FydEc2IywmRidGJyokJSJ4RyIiJEYnISIiL0YtOyIiIUYu</Equation> <Font bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" style="_cstyle296" underline="false">with n = 20 using the trapezoidal rule. Confirm your answer using the </Font><Font executable="false" family="Times New Roman" italic="false" style="_cstyle318" underline="false">trapezoid</Font><Font bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" style="_cstyle319" underline="false"> command and compare it with the result given by the </Font><Font executable="false" family="Times New Roman" italic="false" style="_cstyle320" underline="false">int</Font><Font bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" style="_cstyle321" underline="false"> command.</Font></Text-field>restart;with(student):
<Text-field layout="Heading 2" style="Heading 2"><Font bold="false">Exercise 3: Use Simpson's Rule to approximate int(sin(x^2), x = 0 .. sqrt(Pi)) with n = 20 and compare the result with those given by the <Font foreground="[255,0,51]">midpoint</Font> comand, the <Font foreground="[255,0,51]">trapezoid</Font> command, and the int command. Confirm that your solution is a linear combination of the midpoint rule and trapezoid rule using MAPLE.<Font style="Text">K</Font></Font></Text-field>restart:with(student):
<Text-field layout="Heading 2" style="Heading 2">Exercise 4: Find the size of <Font bold="false" italic="true">n</Font><Font bold="false"> necessary to approximate the integral </Font><Equation input-equation="int(exp(-x^2), x = 3 .. 4)" style="2D Math">NiMtSSRpbnRHNiRJKnByb3RlY3RlZEdGJkkoX3N5c2xpYkc2IjYkLUkkZXhwR0YlNiMsJCokSSJ4R0YoIiIjISIiL0YvOyIiJCIiJQ==</Equation><Font bold="false"> to within 0.0001 of the actual integral then use the <Font italic="true">n</Font> you find to compute the value. You will want to use the error approximation given in class. </Font></Text-field>restart:with(student):