The Write a function that will return an approximate value for pi by evaluating the equation pi = arctan(1/5) – arctan(1/239), where arctan is the tangent function from the math library . Im using python 3.4.1
The function I used was:
def wallis(pairs): acc = 1 num = 2 for apair in range(pairs): leftterm = math.atan(0.2) rightterm = math.atan(0.0041) acc = leftterm - rightterm return pi
but it didn't work. It's confusing.