def f(x):
return (1/3)*x**3-2*x**2+2
def méthode_1(p):
a=0
b=4
while abs(b-a)>=10**(-p):
c=(a+b)/2
if f(c)>-2:
a=c
else:
b=c
return a, b
print (méthode_1(3))
def nbrdériv(a):
h=10**(-9)
return (f(a+h)-f(a))/h
print(nbrdériv(4))
def méthode_2(p):
x=6
while f(x)>=10**(-p):
x=x-f(x)/nbrdériv(x)
return x
print(méthode_2(3))
To embed this project on your website, copy the following code and paste it into your website's HTML: