Apr 29, 2025

Wiki

Python

Aide

edit SideBar

Search

Dichotomie

  def dichoto(f, a, b, epsilon):
      c=(a+b)/2
      if abs(f(c)) < epsilon:
          return c
      elif f(a)*f(c) < 0:
          return dichoto(f, a, c, epsilon)
      else:
          return dichoto(f, c, b, epsilon)


  def f(x):
      return x**3-x-1


  dichoto(f, 0, 2, 0.01)
  Out: 1.32421875

Page Actions

Recent Changes

Group & Page

Back Links