import mpmath as mp mp.mp.dps = 1000 pi = 2 * mp.quad(lambda x: mp.sqrt(1 - x**2), [-1, 1]) print(pi)