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 x = a
symbol = symbols("x") symbol = symbols("x")
exp = sympify( # expressions to be represented symbolically and manipulated algebraically
func exp = sympify(func)
) # expressions to be represented symbolically and manipulated algebraically # calculate the derivative value at the current x value
exp_diff = diff( exp_diff = diff(exp, symbol)
exp, symbol
) # calculates the derivative value at the current x value
maximum_iterations = 100 maximum_iterations = 100
for _ in range(maximum_iterations): for _ in range(maximum_iterations):