# Assignment B

You will write a function to evaluate Boole's rule in Python. Consider the integral $\int_a^b f(x)\,dx$ where $$f$$ is twice continuously differentiable. Let $$a=x_0\lt x_1\lt\dots\lt x_n=b$$ be an equally-spaced partition of $$[a,b]$$, where we assume that $$n$$ is evenly divided by 4. When $$h=(b-a)/n$$ is the uniform width of the subintervals, the composite Boole rule is $$\int_a^b f(x)\,dx = \frac{4h}{90}\sum_{i=1}^{n/4} \left( 7f(x_{4i-4})+32f(x_{4i-3})+12f(x_{4i-2})+32f(x_{4i-1})+7f(x_{4i}) \right) + O(h^6). \qquad\qquad (1)$$ Write a Python function called boole that takes four arguments: an integrand function, the lower and upper limits of integration, and the value of $$n$$, which returns the value of the Boole's rule approximation to the integral. Be sure your function tests whether $$n$$ is divisible by 4. If not, it should produce an error message.

Once you finish your boole() function, you will write a name function that uses both your first and last names The function will take a vector $$x$$ as input, and return the name exponential using the rules we developed earlier in the semester, but using both your first and last names. Test the name function and boole function and be sure they work and are right. Use the Boole function to evaluate the integral of your two-name function on the interval [-1,7] to 10 decimal digits. Explain in the comments for your file how you made sure the answer was correct.

For emphasis, this assignment uses a name function for both your first and last names. This assignment is worth 40 points. Send the completed .py file containing the functions as an attachment to an email message to the instructor by 9:00 AM on Thursday, 29 November.

Assignment C is posted.

The test solution is available.

Department of Mathematics, PO Box 643113, Neill Hall 103, Washington State University, Pullman WA 99164-3113, 509-335-3926, Contact Us