Post Reply 
Viète's Formula for PI
06-23-2020, 06:39 PM
Post: #6
RE: Viète's Formula for PI
(06-18-2020 12:51 PM)pinkman Wrote:  And the convergence speed is acceptable : for p(18) we have 10 digits.
p(18) means Σ(x,x,1,18) = 171 iterations.

For faster convergence, you might want to try this algorithm:
Code:

Program  Viete;                                                                                 
                                                                                                                    
Uses Crt;                                                                                                            
                                                                                                                    
var         k:  Byte;                                                                                                
            n: LongInt;                                                                                             
            c: Char;                                                                                                
   d, p, t, v: Extended;                                                                                             
                                                                                                                     
begin                                                                                                               
  ClrScr;                                                                                                           
  WriteLn('+---+----------------------+----------------------+');                                                    
  WriteLn('| k |         2*v          |         ~ pi         |');                                                    
  WriteLn('+---+----------------------+----------------------+');                                                    
  v := 1;                                                                                                            
  n := 1;                                                                                                           
  d := 0;                                                                                                           
  for k := 1 to 15 do                                                                                                
    begin                                                                                                           
      n := n + n;                                                                                                   
      d := Sqrt(d + 2);                                                                                             
      v := v*d;                                                                                                      
      t := 6*v*v - 2/3;                                                                                             
      p := 2*n/v*(t + 1)/t;                                                                                         
      WriteLn('|',k:2,' |',2*n/v:21:18,' |',p:21:18,' |')
    end;                                                                                                             
  WriteLn('+---+----------------------+----------------------+');                                                   
  c := ReadKey                                                                                                       
end.

+---+----------------------+----------------------+
| k |         2*v          |         ~ pi         |
+---+----------------------+----------------------+
| 1 | 2.828427124746190098 | 3.077994223988500989 |
| 2 | 3.061467458920718174 | 3.137427049842311165 |
| 3 | 3.121445152258052286 | 3.141329731135014592 |
| 4 | 3.136548490545939264 | 3.141576182507746574 |
| 5 | 3.140331156954752913 | 3.141591623553754287 |
| 6 | 3.141277250932772868 | 3.141592589203296386 |
| 7 | 3.141513801144301077 | 3.141592649565492850 |
| 8 | 3.141572940367091385 | 3.141592653338272210 |
| 9 | 3.141587725277159701 | 3.141592653574073140 |
|10 | 3.141591421511199975 | 3.141592653588810732 |
|11 | 3.141592345570117743 | 3.141592653589731833 |
|12 | 3.141592576584872667 | 3.141592653589789401 |
|13 | 3.141592634338562990 | 3.141592653589793000 |
|14 | 3.141592648776985670 | 3.141592653589793224 |
|15 | 3.141592652386591346 | 3.141592653589793238 |
+---+----------------------+----------------------+
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Viète's Formula for PI - pinkman - 06-17-2020, 05:06 PM
RE: Viète's Formula for PI - ramon_ea1gth - 06-17-2020, 09:37 PM
RE: Viète's Formula for PI - pinkman - 06-18-2020, 12:51 PM
RE: Viète's Formula for PI - Gerson W. Barbosa - 06-23-2020 06:39 PM
RE: Viète's Formula for PI - pinkman - 06-23-2020, 10:04 PM
RE: Viète's Formula for PI - cdmackay - 06-19-2020, 09:00 PM
RE: Viète's Formula for PI - pinkman - 06-23-2020, 09:58 PM
RE: Viète's Formula for PI - pinkman - 07-16-2020, 04:42 PM
RE: Viète's Formula for PI - pinkman - 06-24-2020, 01:15 PM
RE: Viète's Formula for PI - CyberAngel - 06-29-2020, 05:52 AM
RE: Viète's Formula for PI - pinkman - 06-29-2020, 10:54 PM
RE: Viète's Formula for PI - compsystems - 06-30-2020, 03:05 PM



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