In numerical analysis, Newton's method, also known as the Newton – Raphson method, named after Isaac Newton and Joseph Raphson, is a root-finding algorithm which produces successively better approximations to the beginnings (or zeroes) of a real-valued function. The most basic version begins with a individual-variable function f specify for a real variable X, the function's derivative F ′, and an initial guess x0 for a root of f. Raphson again viewed Newton's method purely as an algebraic method and restricted its purpose to polynomials, but he describes the method in terms of the successive approximations xn instead of the more complicated sequence of polynomials used by Newton. The name" Newton's method" is derived from Isaac Newton's description of a special case of the method in De analysi per aequationesFinally, in 1740, Thomas Simpson described Newton's method as an iterative method for solve general nonlinear equations use calculus, essentially give the description above.
"""Newton's Method.""" # Newton's Method - https://en.wikipedia.org/wiki/Newton%27s_method # function is the f(x) and function1 is the f'(x) def newton(function, function1, startingInt): x_n = startingInt while True: x_n1 = x_n - function(x_n) / function1(x_n) if abs(x_n - x_n1) < 10 ** -5: return x_n1 x_n = x_n1 def f(x): return (x ** 3) - (2 * x) - 5 def f1(x): return 3 * (x ** 2) - 2 if __name__ == "__main__": print(newton(f, f1, 3))