From: Fred lunnon <fred.lunnon@gmail.com> To: math-fun <math-fun@mailman.xmission.com> Sent: Thursday, March 26, 2009 7:12:35 PM Subject: Re: [math-fun] Simpsons' rules On 3/26/09, Eugene Salamin <gene_salamin@yahoo.com> wrote:
If I'm integrating over a circle, so that there is no boundary, then one point is as good as another, and I would expect the best approximation to be to give equal weights to each point. Now if instead, I integrate over an interval, there are some boundary effects, but deep within the interval , why would I want to do otherwise than to weight the points equally?
-- Gene
Two reasons I might (tentatively) suggest: (i) You might want to be able to predict the error a priori, subject to some assumptions about the integrand (e.g. analyticity); (ii) You might want to ensure that some smaller class be integrated exactly, or at least to within working precision (e.g. quadratic polynomials). I can't say that I've ever been very convinced by these arguments either --- if left to my own devices and in a hurry, I usually fall back on Romberg's method (which at a pinch can also be tweaked to serve for ordinary differential equations). Fred Lunnon _______________________________________________ If we evaluate the integrand at n points, and are free to choose both the locations and weights, we have 2n degrees of freedom. In Gaussian Quadrature, the choice is made so that all polynomials of degree 2n-1 or less are integrated exactly. Scaling the interval to [-1,+1], the locations are the n roots of the n-th Legendre polynomial, P[n](x[i]) = 0, i = 1..n. The weights are w[i] = 2 / ( (1 - x[i]^2) (P[n]'(x[i]))^2 ). Here, P[n]' is the derivative of P[n]. I've worked out some examples comparing Simpson's rule with Gaussian Quadrature, over [-1,+1], and using the same number n of integrand evaluations. f(x) = exp(x), n = 3, Simpson's error = 0.012, GQ error = 6.5e-5. f(x) = exp(x), n = 13, Simpson's error = 1.0e-5, GQ error = 1.1e-34. f(x) = cos((pi / 2) x), n = 3, Simpson's error = 0.047, GQ error = 6.9e-4. f(x) = cos((pi / 2) x), n = 13, Simpson's error = 2.6e-5, GQ error = 1.1e-29. -- Gene