Department of Mathematics

Math 300: Mathematical Computing

The Midpoint Rule

One alternative to the composite trapezoidal rule for integrating functions is to use the midpoint rule. The midpoint rule is simply a Riemann sum in which the points where the function is evaluated are the midpoints of subintervals of the interval of integration. Specifically, 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]\), and let \(z_i=(x_i+x_{i-1})/2\) for \(i=1,2,\dots,n\) denote the midpoints of the subintervals defined by the \(x_i\) values. When \(h=(b-a)/n\) is the uniform width of the subintervals, the midpoint rule is \[\int_a^b f(x)\,dx = h\sum_{i=1}^n f(z_i) + O(h^2). \] Write a Matlab function 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 midpoint approximation to the integral.


Assignment 6 is posted.




The midterm exam will take place Monday, 16 October. As with all exams, all paper notes may be used, but no electronic devices are permitted. There is a sample exam available.



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