mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 10:28:39 +00:00
Update newton_raphson.py (#891)
This commit is contained in:
parent
9b945cb2b4
commit
066f37402d
@ -33,7 +33,7 @@ def newton_raphson(f, x0=0, maxiter=100, step=0.0001, maxerror=1e-6,logsteps=Fal
|
|||||||
if error < maxerror:
|
if error < maxerror:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise ValueError("Itheration limit reached, no converging solution found")
|
raise ValueError("Iteration limit reached, no converging solution found")
|
||||||
if logsteps:
|
if logsteps:
|
||||||
#If logstep is true, then log intermediate steps
|
#If logstep is true, then log intermediate steps
|
||||||
return a, error, steps
|
return a, error, steps
|
||||||
@ -47,4 +47,4 @@ if __name__ == '__main__':
|
|||||||
plt.xlabel("step")
|
plt.xlabel("step")
|
||||||
plt.ylabel("error")
|
plt.ylabel("error")
|
||||||
plt.show()
|
plt.show()
|
||||||
print("solution = {%f}, error = {%f}" % (solution, error))
|
print("solution = {%f}, error = {%f}" % (solution, error))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user