20 lines
348 B
Python
Executable File
20 lines
348 B
Python
Executable File
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Created on Fri Jan 10 09:17:36 2020
|
|
|
|
@author: suwako
|
|
"""
|
|
|
|
import scipy
|
|
import numpy as np
|
|
def dichotomie(f, a, b, epsilon=1e-15):
|
|
g, d = a, b
|
|
while abs(g - d) > 2*epsilon:
|
|
m = (g+d)/2.
|
|
if f(g)*f(m) <= 0:
|
|
d = m
|
|
else:
|
|
g = m
|
|
return (g+d)/m
|