Department of Mathematics

Math 583: Mathematical Hacking

Assignment 1

Write a Python function called simpson that takes four arguments. The first argument is the name of a function whose integral is to be approximated using a composite Simpson's rule. The second and third arguments are the left and right endpoints of the interval of integration. The last argument is the number of subintervals over which the Simpson's rule will be applied. The output of the function is the value of the approximation to the integral. Note that the function must test the number of subintervals input, and if that number is odd or nonpositive, it must stop the function with an error message. The function must not use a for loop.

You will email the Python file to the instructor to turn the assignment in. The assignment is worth 25 points and is due in the instructor's email inbox by 9:00 AM on Thursday, 15 February.

Assignment 1 is posted.

Department of Mathematics, PO Box 643113, Neill Hall 103, Washington State University, Pullman WA 99164-3113, 509-335-3926, Contact Us
Copyright © 2009-15 Kevin Cooper