From 4074513e9c79b7adb6cc4890a1dcec3f1b24cd8c Mon Sep 17 00:00:00 2001 From: Rohan Anand <96521078+rohan472000@users.noreply.github.com> Date: Sun, 16 Jul 2023 12:51:54 +0530 Subject: [PATCH] Update arithmetic_analysis/newton_raphson.py Co-authored-by: Christian Clauss --- arithmetic_analysis/newton_raphson.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arithmetic_analysis/newton_raphson.py b/arithmetic_analysis/newton_raphson.py index 27a70bf0c..b3fcd6c41 100644 --- a/arithmetic_analysis/newton_raphson.py +++ b/arithmetic_analysis/newton_raphson.py @@ -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):