From baa524385a8088f5d7f95437a301e3bf48673625 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 16 Jul 2023 06:51:54 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- arithmetic_analysis/newton_raphson.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arithmetic_analysis/newton_raphson.py b/arithmetic_analysis/newton_raphson.py index 50674be63..27a70bf0c 100644 --- a/arithmetic_analysis/newton_raphson.py +++ b/arithmetic_analysis/newton_raphson.py @@ -7,9 +7,7 @@ from __future__ import annotations from sympy import diff, symbols, sympify -def newton_raphson( - func: str, a: float, precision: float = 10**-10 -) -> float: +def newton_raphson(func: str, a: float, precision: float = 10**-10) -> float: """Finds root from the point 'a' onwards by Newton-Raphson method >>> newton_raphson("sin(x)", 2) 3.1415926536808043 @@ -21,9 +19,13 @@ def newton_raphson( 2.718281828458938 """ 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 + 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 maximum_iterations = 100 for _ in range(maximum_iterations):