I’ve never read Numerical Methods That Work, but it sounds like something I should. I’ll put it on my (ever growing) Goodreads “to read” list.

Subtracting out singularities before numerical integration has a long history outside of computing. I learned the method in Complex Analysis class*. We found the singularities or poles and drew circles in complex space about each. We then integrated the well-behaved portions piece-wise.

Lastly, we computed the areas in the circles in the complex plane as the limit of their radii approached zero and added those areas to the piece-wise sum.

Really so elegant.

* I took the CA class/seminar with Stephen Smale. He seemed a bit distant and distracted and I thought that was just his personality. I had no idea he was embroiled in this mess at the same time. (Scroll to the link at the bottom.)

http://badmomgoodmom.blogspot.com/2007/08/gaia-girl-named-me-rockin-girl-blogger.html

For example, fractions(exp(1)-2) gives 719/1001, which agrees with the 2721/1001 = 2002 + 719/1001 answer above. Higher values of the “cycle” argument work too.

]]>I’m wondering, is there a connection between this and the so-called control variates (this approach sounds very similar, I have a vague recollection this analogy might have been mentioned in the “Numerical Recipes” book as smoothing out the integrand graph, but I’m not sure if there are any formal equivalence theorems or the like), http://en.wikipedia.org/wiki/Control_variates#Example

]]>For example, Acton talks about catastrophic loss of precision with single precisions arithmetic. Now everything is done in double precision, and that’s enough to save you from the specific problem he gives. But with a minor change to the problem you’ll have the same problem in double precision.

I’m always using integration techniques I learned from that book, such as subtracting off a singularity before doing numerical integration then adding back the analytic integral of the singular part.

As for continued fractions, I used to think they were just for recreational math, an amusing typographical novelty. And yet I continually run into them. They often give the best numerical algorithm for evaluating some function.

]]>