Update arithmetic_analysis/newton_raphson.py

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Rohan Anand 2023-07-16 12:51:54 +05:30 committed by GitHub
parent baa524385a
commit 4074513e9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,12 +20,10 @@ def newton_raphson(func: str, a: float, precision: float = 10**-10) -> float:
"""
x = a
symbol = symbols("x")
exp = sympify(
func
) # expressions to be represented symbolically and manipulated algebraically
exp_diff = diff(
exp, symbol
) # calculates the derivative value at the current x value
# expressions to be represented symbolically and manipulated algebraically
exp = sympify(func)
# calculate the derivative value at the current x value
exp_diff = diff(exp, symbol)
maximum_iterations = 100
for _ in range(maximum_iterations):