{"record":{"id":"a0f2e73990d4dbc7","repo":"TheAlgorithms/Python","slug":"no-converging-solution-found-zero-derivative","errorCode":null,"errorMessage":"No converging solution found, zero derivative","messagePattern":"No converging solution found, zero derivative","errorType":"exception","errorClass":"ZeroDivisionError","httpStatus":null,"severity":"error","filePath":"maths/numerical_analysis/newton_raphson.py","lineNumber":96,"sourceCode":"    ...\n    ArithmeticError: No converging solution found, iteration limit reached\n    \"\"\"\n\n    def f_derivative(x: float) -> float:\n        return calc_derivative(f, x, step)\n\n    a = x0  # Set initial guess\n    steps = []\n    for _ in range(max_iter):\n        if log_steps:  # Log intermediate steps\n            steps.append(a)\n\n        error = abs(f(a))\n        if error < max_error:\n            return a, error, steps\n\n        if f_derivative(a) == 0:\n            raise ZeroDivisionError(\"No converging solution found, zero derivative\")\n        a -= f(a) / f_derivative(a)  # Calculate next estimate\n    raise ArithmeticError(\"No converging solution found, iteration limit reached\")\n\n\nif __name__ == \"__main__\":\n    import doctest\n    from math import exp, tanh\n\n    doctest.testmod()\n\n    def func(x: float) -> float:\n        return tanh(x) ** 2 - exp(3 * x)\n\n    solution, err, steps = newton_raphson(\n        func, x0=10, max_iter=100, step=1e-6, log_steps=True\n    )\n    print(f\"{solution=}, {err=}\")\n    print(\"\\n\".join(str(x) for x in steps))","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/maths/numerical_analysis/newton_raphson.py#L78-L114","documentation":"Error \"No converging solution found, zero derivative\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at maths/numerical_analysis/newton_raphson.py:96 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pick a starting point where the derivative is non-zero.","Use a bracketing method (bisection) when the derivative vanishes near the root."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}