From daf594dd500a0000c6c429113a49783c2fcdd9ff Mon Sep 17 00:00:00 2001 From: Rohan Anand <96521078+rohan472000@users.noreply.github.com> Date: Sun, 16 Jul 2023 20:42:27 +0530 Subject: [PATCH] Update arithmetic_analysis/newton_raphson.py Co-authored-by: Christian Clauss --- arithmetic_analysis/newton_raphson.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arithmetic_analysis/newton_raphson.py b/arithmetic_analysis/newton_raphson.py index afa2040d0..0cb4598f6 100644 --- a/arithmetic_analysis/newton_raphson.py +++ b/arithmetic_analysis/newton_raphson.py @@ -19,6 +19,17 @@ def newton_raphson( 2.23606797749979 >>> newton_raphson("log(x)- 1", 2) 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 symbol = symbols("x")