Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"06-13-09 - A little mathemagic"

3 Comments -

1 – 3 of 3
Blogger ryg said...

Numerical integration: One thing that's really handy to know is Romberg integration; it's a relatively short but sweet extension of the trapezoid rule integration functional. The basic idea is rather simple: Treat the value of the integral as a function I(h) of your step size h. The first step uses one unsubdivided evaluation of the trapezoid rule for the interval [a,b], so h_0=b-a. The second step subdivides the interval in the middle, the third subdivides the resulting two intervals in the middle, and so on. That gives you a sequence of I(h_0), I(h_0/2), ..., I(h_0/(2^k)); fit a polynomial through this, your integral estimate is the extrapolated value for I(0). Understanding the idea is idea, proving that it works most definitely isn't :). Romberg integration works well for smooth functions or nearly-smooth functions with known discontinuities - and for everything else, you probably want to use Monte Carlo techniques anyway. The code works out beautifully as well: for the trapezoid rule evaluations, you can recycle the sum from the previous k and only add the new points. The polynomial evaluation is best done using Neville's algorithm. Finally, for the trapezoid rule, you can use a polynomial in h^2 instead of h for better convergence speed (explanation why is, again, nontrivial; it relies on properties of the error term expansion that's used in the convergence proof).

It's really a rather elegant algorithm - there's a lot of math working in the background, but the actual code ends up very short and clean.

As your post is both about numerical integration and orthogonal polynomials, gaussian quadratures deserve at least a honorary mention. The proof of the fundamental theorem mentioned in the article is really worth studying; it's, again, a beautiful piece of math, since everything falls so neatly into place - and the conclusion is anything but obvious.

Finally, a really great resource on approximating functions numerically is Robin Greens GDC 2003 talk on the subject: part 1, part 2. It's terrific, and not nearly as well-known as it should be.

June 13, 2009 at 4:03 PM

Blogger cbloom said...

Whoah yeah Robin's talk is awesome, I've seen some similar material from him before but never the full talk slides. It's chock full of craziness.

June 13, 2009 at 5:49 PM

Blogger won3d said...

I learned
the differential equation version of Romberg integration in high school, and it totally blew my mind.

Those Robin Green slides are way cool. The part on polynomial evaluation was surprising!

June 15, 2009 at 10:30 AM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.