Skip to content

Commit 122cf45

Browse files
authored
Update NeutonMethod.py
Removing requirement of math library to make code faster
1 parent 335bc2e commit 122cf45

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Diff for: NeutonMethod.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import math
2-
31
def newton(function,function1,startingInt): #function is the f(x) and function1 is the f'(x)
42
x_n=startingInt
53
while True:
@@ -9,9 +7,9 @@ def newton(function,function1,startingInt): #function is the f(x) and function1
97
x_n=x_n1
108

119
def f(x):
12-
return math.pow(x,3)-2*x-5
10+
return (x**3)-2*x-5
1311

1412
def f1(x):
15-
return 3*math.pow(x,2)-2
13+
return 3*(x**2)-2
1614

17-
print(newton(f,f1,3))
15+
print(newton(f,f1,3))

0 commit comments

Comments
 (0)