dichotomie_racine_de_deux.py

Created by elodie-gamot

Created on November 10, 2021

243 Bytes

Algorithme de dichotomie afin de déterminer un encadrement de sqrt(2)


from math import *
  
def encadrement(e):
  a=1
  b=2
  while b-a>e:
    c=(a+b)/2
    if f(a)*f(c)>0:
      a=c
    else:
      b=c
  print("La valeur est comprise entre",a,"et",b)
  
def f(x):
  return x**2-2

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.