2.5 Accumulator Approximations

The pi approximation techniques that follow will use mathematics based on infinite series and infinite product expansions. The basic idea is that by adding or multiplying an infinite number of arithmetic terms, we can get increasingly closer to the actual value we are trying to compute. Although the mathematics of these approaches is beyond the scope of this text, the patterns provide excellent examples of arithmetic processing.

2.5.1 The Accumulator Pattern

To use these techniques, we will need to introduce another important problem-solving pattern known as the accumulator pattern. Your ability to recognize this commonly occurring pattern and then implement it will be especially useful as you encounter new ...

Get Python Programming in Context, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.