import matplotlib.pyplot as plt
import numpy as np

def suite(N,a) :
    L = [a]
    for _ in range(1,N) :
        u = L[-1]
        v = np.arctan(u/(1+np.sqrt(1+u**2)))
        L.append(v)
    return L
    
# une programmation récursive plante pour suite(2**10,a)

print(suite(3,0))
print(suite(10,2019))

for a in [1,4,10,100] :
    print("u50(",a,")=",suite(50,a)[-1])
    
def f(x) :
    n = 10
    return 2**n*suite(n,x)[-1]
    
X = np.arange(-30,30,0.01)
Y = [f(x) for x in X]
plt.plot(X,Y)
plt.show()