Department of Mathematics

Math 583: Mathematical Hacking

Python ICE 4

Given uniformly spaced points \(a=x_0\lt x_1\lt \dots\lt x_n=b\), with \(x_{i+1}-x_i=h\) for every \(i\), the composite midpoint rule for approximating the integral of a function \(f\) is given by $$ \int_a^b f(x) dx\approx \sum_{i=0}^{n-1} f\left(\frac{x_i+x_{i+1}}{2}\right) h $$ Write a Python function called midpoint to evaluate a midpoint rule approximate to any function \(f\) we specify. We will call the midpoint function as midpoint(f,a,b,n), with arguments as in our other approximate integral functions. For \(a\) and \(b\) we choose, use it to evaluate \[\int_a^b \sqrt{1+\left(\frac{d}{dx}x^{3/2}\right)^2}\,dx\] and display the result in a string: "The arc length of x^(3/2) from ___ to ___ is ___".

Send the result to the instructor at the end of class.

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