Update arithmetic_analysis/newton_raphson.py

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Rohan Anand 2023-07-16 20:42:27 +05:30 committed by GitHub
parent 7b7a149b06
commit daf594dd50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,17 @@ def newton_raphson(
2.23606797749979 2.23606797749979
>>> newton_raphson("log(x)- 1", 2) >>> newton_raphson("log(x)- 1", 2)
2.718281828458938 2.718281828458938
>>> from scipy.optimize import newton
>>> all(newton_raphson("log(x)- 1", 2) == newton("log(x)- 1", 2) for precision in 10, 100, 1000, 10000))
True
>>> newton_raphson("log(x)- 1", 2, 0)
Traceback (most recent call last):
...
ValueError: precision must be greater than zero
>>> newton_raphson("log(x)- 1", 2, -1)
Traceback (most recent call last):
...
ValueError: precision must be greater than zero
""" """
x = start_point x = start_point
symbol = symbols("x") symbol = symbols("x")