The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function

 Wallis' product exploration
02-07-2020, 10:55 PM
Post: #1
 pinkman Senior Member Posts: 432 Joined: Mar 2018
Wallis' product exploration
Last week my cousin told me Wallis' product was quite his favorite formula in mathematics.

I remembered the thread opened on this forum about PI approximations (like 355 / 113), and we decided to program Wallis product on Free42 while having a coffee...

We built it this way:
Code:
 01 LBL "WALLIS" 02 1 03 STO+ 00     // n++ (n is register 00) 04 RCL 00      // recl n 05 X^2         // this is n^2 06 4 07 x           // 4n^2 (numerator) 08 ENTER       // duplicate 09 X<>Y        // enable stack lift 10 1 11 -           // 4n^2 - 1 (denominator) 12 /           // 4n^2 / (4n^2 - 1) 13 STOx 01     // pi/2 approximation is in register 01 14 RCL 01 15 2 16 x           // (pi/2 approximation) x 2 17 RTN

The usage is simple:
- initiate n with value 0 in register 00: 0 STO 00
- then initiate product with value 1 in register 01: 1 STO 01
- execute the product as many times as you want: XEQ WALLIS

We were really disapointed!
First iteration: 2.6666...
2nd: 2.844444...
3rd: 2.9...
10th: 3.067...
50th: 3.126...

Yes the product seems to approach PI/2, but soooooo slowly!

My other program included a loop until the precision of the calculator has been reached:
Code:
 01 LBL "PICALC" 02 RCL 01      // take last PI/2 approximation... 03 STO 02      // ... and save it 04 1 05 STO+ 00     // n++ (n is register 00) 06 RCL 00      // recl n 07 X^2         // this is n^2 08 4 09 x           // 4n^2 (numerator) 10 ENTER       // duplicate 11 X<>Y        // enable stack lift 12 1 13 -           // 4n^2 - 1 (denominator) 14 /           // 4n^2 / (4n^2 - 1) 15 STOx 01     // pi/2 approximation is in register 01 16 RCL 01      // recl pi/2 current approximation 17 RCL 02      //  recl pi/2 previous approximation 18 - 19 X≠0?        // if maximum calculator precision has not been reached then... 20 GTO "PICALC"   // ... loop and calculate another one 21 RCL 01      // we're done, prove it 22 2 23 x           // by calculating 2 x pi/2 approximation 24 RTN

I tried it a few times and breaked the program after several minutes to get 7 correct significant digits of pi after... 100E6 iterations.

Despite the fact that Wallis' product is really slow (and it's very deceptive), I have one question:
What do you think about calculations precisions?
- I mean, at first iteration the number is rounded, because pi/2 is approximated by 1.3333.... so errors will appear, and will be multiplied at each loop. I even wondered if those approximations could be a reason for the convergence being so slow.
- I also mean, each time we iterate, we calculate a square of big numbers, approaching the limit of the calculator, leading to (4n^2) = (4n^2 - 1) => (4n^2)/(4n^2 - 1) = 1, but, unless my algorithm is wrong, I did not reach the limit.
 « Next Oldest | Next Newest »

 Messages In This Thread Wallis' product exploration - pinkman - 02-07-2020 10:55 PM RE: Wallis' product exploration - Albert Chan - 02-08-2020, 02:13 AM RE: Wallis' product exploration - pinkman - 02-08-2020, 02:42 PM RE: Wallis' product exploration - Allen - 02-08-2020, 07:13 PM RE: Wallis' product exploration - Albert Chan - 02-08-2020, 07:53 PM RE: Wallis' product exploration - Allen - 02-08-2020, 08:58 PM RE: Wallis' product exploration - pinkman - 02-09-2020, 05:44 AM RE: Wallis' product exploration - Allen - 02-08-2020, 08:13 PM RE: Wallis' product exploration - Allen - 02-09-2020, 01:08 PM RE: Wallis' product exploration - Allen - 02-09-2020, 01:57 PM RE: Wallis' product exploration - Allen - 02-09-2020, 03:08 PM RE: Wallis' product exploration - pinkman - 02-09-2020, 02:14 PM RE: Wallis' product exploration - Gerson W. Barbosa - 02-09-2020, 10:58 PM RE: Wallis' product exploration - Gerson W. Barbosa - 02-11-2020, 12:53 AM RE: Wallis' product exploration - EdS2 - 02-10-2020, 10:35 AM RE: Wallis' product exploration - pinkman - 02-11-2020, 10:02 AM RE: Wallis' product exploration - Gerson W. Barbosa - 02-11-2020, 04:11 PM RE: Wallis' product exploration - Gerson W. Barbosa - 02-11-2020, 10:48 PM RE: Wallis' product exploration - pinkman - 02-12-2020, 10:01 PM RE: Wallis' product exploration - Gerson W. Barbosa - 02-13-2020, 12:17 AM

User(s) browsing this thread: 1 Guest(s)