{"record":{"id":"77ac06144c893cf6","repo":"TheAlgorithms/Python","slug":"no-converging-solution-found-iteration-limit-reac","errorCode":null,"errorMessage":"No converging solution found, iteration limit reached","messagePattern":"No converging solution found, iteration limit reached","errorType":"exception","errorClass":"ArithmeticError","httpStatus":null,"severity":"error","filePath":"maths/numerical_analysis/newton_raphson.py","lineNumber":98,"sourceCode":"    \"\"\"\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))\n","sourceCodeStart":80,"sourceCodeEnd":115,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/maths/numerical_analysis/newton_raphson.py#L80-L115","documentation":"Error \"No converging solution found, iteration limit reached\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at maths/numerical_analysis/newton_raphson.py:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase the maximum iteration limit.","Relax the tolerance or choose a better initial guess closer to 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-15T22:17:37.221Z"}