**Computing the digits of \pi**

This method, which uses highly sophisticated iterative techniques and programming, is provided as an illustration of what can be achieved. It is not part of your Advanced Level course!

This program demonstrates arbitrary-precision arithmetic by computing the digits of pi using the Borwein iteration algorithm first published by Jonathan Borwein and Peter Borwein in 1985.

Iteration #1 produces 8 correct decimal digits, iteration #2 produces 41 digits, iteration #3 produces 171 digits, iteration #4 produces 694 digits, and each subsequent iteration increases the number of correct digits by more than a factor of four. Because it needs to test for convergence, the program will do one more iteration than necessary.

This program computes the digits of pi in several phases, and each phase can consist of several tasks. It displays the current phase and task, the elapsed time of the previous phase, and the total elapsed time. (The total elapsed time does not include the time to display the digits of pi).

To ensure the accuracy of the last digits, the program computes with a scale equal to 0.5% more than the specified number of decimal digits. To run the demo:

- Enter the number of decimal digits of pi to compute.
- Press the Run button.
- Press the Stop button at any time to stop the computation.

## Software/Applets used on this page

This applet forms part of "Java Number Cruncher: The Java Programmer's Guide to Numerical Computation", Prentice-Hall, by Ronald Mak, and is provided for MathsNetAlevel-plus by that author - see

Apropos-logic

Apropos-logic

## Glossary

### algorithm

A set of precise instructions which, if followed, will solve a problem.

### iteration

successive repetition of a process using the result of one stage as the input for the next.

### pi

the ratio of the circumference of a circle to its diameter. It is approximately 3.14159265...

## This question appears in the following syllabi:

Syllabus | Module | Section | Topic | Exam Year |
---|---|---|---|---|

AQA A-Level (UK - Pre-2017) | C3 | Numerical Methods | Iterative methods | - |

AQA A2 Maths 2017 | Pure Maths | Numerical Methods | Iteration | - |

AQA AS/A2 Maths 2017 | Pure Maths | Numerical Methods | Iteration | - |

CCEA A-Level (NI) | C3 | Numerical Methods | Iterative methods | - |

CIE A-Level (UK) | P2 | Numerical Methods | Iterative methods | - |

Edexcel A-Level (UK - Pre-2017) | C3 | Numerical Methods | Iterative methods | - |

Edexcel A2 Maths 2017 | Pure Maths | Numerical Methods | Iteration | - |

Edexcel AS/A2 Maths 2017 | Pure Maths | Numerical Methods | Iteration | - |

OCR A-Level (UK - Pre-2017) | C3 | Numerical Methods | Iterative methods | - |

OCR A2 Maths 2017 | Pure Maths | Numerical Methods | Iteration | - |

OCR MEI A2 Maths 2017 | Pure Maths | Numerical Methods | Iteration | - |

OCR-MEI A-Level (UK - Pre-2017) | NM | Numerical Methods | Iterative methods | - |

Pre-U A-Level (UK) | 8 | Numerical Methods | Iterative methods | - |

Scottish Advanced Highers | M3 | Numerical Methods | Iterative methods | - |

Scottish (Highers + Advanced) | AM3 | Numerical Methods | Iterative methods | - |

Universal (all site questions) | N | Numerical Methods | Iterative methods | - |

WJEC A-Level (Wales) | C3 | Numerical Methods | Iterative methods | - |