Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy
- import scipy
- import math
- import sympy
- from decimal import *
- print(math.pi)
- print(numpy.pi)
- print(scipy.pi)
- print(sympy.pi)
- r = 5
- print(math.pi*(r**2))
- print(numpy.pi*(r**2))
- print(scipy.pi*(r**2))
- print(sympy.pi*(r**2))
- def make_pi():
- q, r, t, k, m, x = 1, 0, 1, 1, 3, 3
- for j in range(1000):
- if 4 * q + r - t < m * t:
- yield m
- q, r, t, k, m, x = 10*q, 10*(r-m*t), t, k, (10*(3*q+r))//t - 10*m, x
- else:
- q, r, t, k, m, x = q*k, (2*q+r)*x, t*x, k+1, (q*(7*k+2)+r*x)//(t*x), x+2
- digits = make_pi()
- pi_list = []
- my_array = []
- for i in make_pi():
- my_array.append(str(i))
- my_array = my_array[:1] + ['.'] + my_array[1:]
- big_string = "".join(my_array)
- print "here is a pi as a string:\n %s" % big_string
- pi = Decimal(big_string)
- print("pi is %s" %(Decimal(big_string)))
- r = Decimal(5.0000000000000000000000000000000000000000000)
- print("now we can do math with pi")
- print(Decimal(Decimal(pi)*r**2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement