From 2b365284c80bbc2c7e5676481ed56308a5b1d888 Mon Sep 17 00:00:00 2001 From: PatOnTheBack <51241310+PatOnTheBack@users.noreply.github.com> Date: Sun, 7 Jul 2019 11:45:42 -0400 Subject: [PATCH] Removed Unnecessary Assignment for 'error' Var (#920) `error = abs(f(a))` was declared on line 24 and line 32. It is unnecessary to have in both places. I removed the second instance since it wastes resources to keep redefining the variable inside the for loop. This fixes an [issue found by lgtm](https://lgtm.com/projects/g/TheAlgorithms/Python/snapshot/66c4afbd0f28f9989f35ddbeb5c9263390c5d192/files/maths/newton_raphson.py?sort=name&dir=ASC&mode=heatmap) --- maths/newton_raphson.py | 1 - 1 file changed, 1 deletion(-) diff --git a/maths/newton_raphson.py b/maths/newton_raphson.py index cc6c92734..d89f264ac 100644 --- a/maths/newton_raphson.py +++ b/maths/newton_raphson.py @@ -29,7 +29,6 @@ def newton_raphson(f, x0=0, maxiter=100, step=0.0001, maxerror=1e-6,logsteps=Fal a = a - f(a)/f1(a) #Calculate the next estimate if logsteps: steps.append(a) - error = abs(f(a)) if error < maxerror: break else: