Update NeutonMethod.py

Removing requirement of math library to make code faster
This commit is contained in:
Sayan Bandyopadhyay 2018-01-07 22:38:46 +05:30 committed by GitHub
parent 335bc2e390
commit 122cf4536d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,3 @@
import math
def newton(function,function1,startingInt): #function is the f(x) and function1 is the f'(x) def newton(function,function1,startingInt): #function is the f(x) and function1 is the f'(x)
x_n=startingInt x_n=startingInt
while True: while True:
@ -9,9 +7,9 @@ def newton(function,function1,startingInt): #function is the f(x) and function1
x_n=x_n1 x_n=x_n1
def f(x): def f(x):
return math.pow(x,3)-2*x-5 return (x**3)-2*x-5
def f1(x): def f1(x):
return 3*math.pow(x,2)-2 return 3*(x**2)-2
print(newton(f,f1,3)) print(newton(f,f1,3))