From 122cf4536dab795d6e883108985353b372a5ecf6 Mon Sep 17 00:00:00 2001 From: Sayan Bandyopadhyay Date: Sun, 7 Jan 2018 22:38:46 +0530 Subject: [PATCH] Update NeutonMethod.py Removing requirement of math library to make code faster --- NeutonMethod.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/NeutonMethod.py b/NeutonMethod.py index 791c256af..c3d5efb47 100644 --- a/NeutonMethod.py +++ b/NeutonMethod.py @@ -1,5 +1,3 @@ -import math - def newton(function,function1,startingInt): #function is the f(x) and function1 is the f'(x) x_n=startingInt while True: @@ -9,9 +7,9 @@ def newton(function,function1,startingInt): #function is the f(x) and function1 x_n=x_n1 def f(x): - return math.pow(x,3)-2*x-5 + return (x**3)-2*x-5 def f1(x): - return 3*math.pow(x,2)-2 + return 3*(x**2)-2 -print(newton(f,f1,3)) \ No newline at end of file +print(newton(f,f1,3))