MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / newton

Function newton

arithmetic_analysis/newton_method.py:3–9  ·  view source on GitHub ↗
(function,function1,startingInt)

Source from the content-addressed store, hash-verified

1# Newton's Method - https://en.wikipedia.org/wiki/Newton%27s_method
2
3def newton(function,function1,startingInt): #function is the f(x) and function1 is the f'(x)
4 x_n=startingInt
5 while True:
6 x_n1=x_n-function(x_n)/function1(x_n)
7 if abs(x_n-x_n1) < 10**-5:
8 return x_n1
9 x_n=x_n1
10
11def f(x):
12 return (x**3) - (2 * x) -5

Callers 1

newton_method.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected