Skip to content

Commit 2b36528

Browse files
PatOnTheBackpoyea
authored andcommitted
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)
1 parent 234b0a7 commit 2b36528

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

maths/newton_raphson.py

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def newton_raphson(f, x0=0, maxiter=100, step=0.0001, maxerror=1e-6,logsteps=Fal
2929
a = a - f(a)/f1(a) #Calculate the next estimate
3030
if logsteps:
3131
steps.append(a)
32-
error = abs(f(a))
3332
if error < maxerror:
3433
break
3534
else:

0 commit comments

Comments
 (0)