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.The Midpoint RuleAn 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(%);The Trapezoidal RuleThe 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(%);Simpson' RuleSimpson'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));ExercisesExercise 1: Use the sum command to approximate NiMtJSRpbnRHNiQqJiIiIkYnLSUlc3FydEc2IywmRidGJyokJSJ4RyIiJEYnISIiL0YtOyIiIUYu with n = 20 using the midpoint rule. Confirm your answer using the middlesum command and graph the curve and the rectangles. Then compare it with the result given by the int command.restart;with(student):Exercise 2: Use the sum command to approximate NiMtJSRpbnRHNiQqJiIiIkYnLSUlc3FydEc2IywmRidGJyokJSJ4RyIiJEYnISIiL0YtOyIiIUYu with n = 20 using the trapezoidal rule. Confirm your answer using the trapezoid command and compare it with the result given by the int command.restart;with(student):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 midpoint comand, the trapezoid command, and the int command. Confirm that your solution is a linear combination of the midpoint rule and trapezoid rule using MAPLE.Krestart:with(student):Exercise 4: Find the size of n necessary to approximate the integral NiMtSSRpbnRHNiRJKnByb3RlY3RlZEdGJkkoX3N5c2xpYkc2IjYkLUkkZXhwR0YlNiMsJCokSSJ4R0YoIiIjISIiL0YvOyIiJCIiJQ== to within 0.0001 of the actual integral then use the n you find to compute the value. You will want to use the error approximation given in class. restart:with(student):