Newton's Method
(updated: )
Formula
$$ x_{i + 1} = x_i - \frac{f(x_i)}{f’(x_i)} $$
Where f'(x)
is the derivative.
Example
Say you want to find the value of x in $ x^3 + x - 1 = 0 $1234567891011121314151617def f(x): return x**3 + x -1def d(x): # derivative return 3*x**2 + 1def newton(x, e): while True: if d(x) == 0: return x old = x x = x - f(x)/d(x) if abs(x - old) <= e: return xif __name__ == "__main__": print newton(12.00, 0.0000001)