Created by frederic-junier
Created on October 06, 2019
276 Bytes
encadrement du zéro d’une fonction par dichotomie
def f(x): return 0.25*x**3 - x + 0.375 def dichotomie(f, a, b, p): while b - a > 10**(-p): m = (a + b)/2 if f(m) * f(a) < 0: b = m else: a = m print(a, b, b -a , m) return (a, b) dichotomie(f,0,1,2)