partie4_ex91.py

Created by cahier-indice-algo-1techno

Created on April 22, 2022

304 Bytes


from matplotlib.pyplot import *

def f(x):
    return 1 / (1 + x**2)

def euler(n):
    h = 1 / n
    x = 0
    y = 0
    X = [0]
    Y = [0]
    for k in range(n):
        y = y + h * f(x)
        x = x + h
        X.append(x)
        Y.append(y)
    plot(X, Y)
    grid()
    show()