top of page

Pi adventure

Calculating pi from atan(1)=pi/4 s=s+4*(-1)**(i+1)/(2*i-1)

2526 terms of gives 3.141196770786618

323 terms of gives 3.1446886214033025

452 terms of gives 3.1393802669164748

111 terms of gives 3.150601479819498

77 terms of gives 3.1545791190866574

30 terms of gives 3.108268566698947

3 terms of gives 3.466666666666667

1660 terms of gives 3.140990244005892

2349 terms of gives 3.1420183666398955

49 terms of gives 3.161998692995051


N=10000

import random

print('Calculating pi from atan(1)=pi/4 s=s+4*(-1)**(i+1)/(2*i-1)')

for j in range(10):

N=int((10**4)**random.random())

s=0.0

import numpy as np

for i in range(1,N):

s=s+4*(-1)**(i+1)/(2*i-1)

print(N-1,'terms of gives ', s)

Recent Posts

See All
How the adventure began

[10/25, 12:54] harish ravishankar: Saw html middle of class x1 instead of right click open text file of saved random page in class 7 [10/25, 12:59] harish ravishankar: That shifted interest to physics

 
 
 

Comments


bottom of page