How to resolve the algorithm Check Machin-like formulas step by step in the Phix programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Check Machin-like formulas step by step in the Phix programming language

Table of Contents

Problem Statement

Machin-like formulas   are useful for efficiently computing numerical approximations for

π

{\displaystyle \pi }

Verify the following Machin-like formulas are correct by calculating the value of tan   (right hand side) for each equation using exact arithmetic and showing they equal 1: and confirm that the following formula is incorrect by showing   tan   (right hand side)   is not   1: These identities are useful in calculating the values:

You can store the equations in any convenient data structure, but for extra credit parse them from human-readable text input. Note: to formally prove the formula correct, it would have to be shown that

− 3 p i

4

{\displaystyle {-3pi \over 4}}

< right hand side <

5 p i

4

{\displaystyle {5pi \over 4}}

due to

tan ⁡ ( )

{\displaystyle \tan()}

periodicity.

Let's start with the solution: