{"record":{"id":"28953f1097f76a6c","repo":"TheAlgorithms/Python","slug":"wrong-space","errorCode":null,"errorMessage":"Wrong space!","messagePattern":"Wrong space!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"maths/numerical_analysis/bisection_2.py","lineNumber":40,"sourceCode":"    9.99\n    \"\"\"\n    return 10 - x * x\n\n\ndef bisection(a: float, b: float) -> float:\n    \"\"\"\n    >>> bisection(-2, 5)\n    3.1611328125\n    >>> bisection(0, 6)\n    3.158203125\n    >>> bisection(2, 3)\n    Traceback (most recent call last):\n        ...\n    ValueError: Wrong space!\n    \"\"\"\n    # Bolzano theory in order to find if there is a root between a and b\n    if equation(a) * equation(b) >= 0:\n        raise ValueError(\"Wrong space!\")\n\n    c = a\n    while (b - a) >= 0.01:\n        # Find middle point\n        c = (a + b) / 2\n        # Check if middle point is root\n        if equation(c) == 0.0:\n            break\n        # Decide the side to repeat the steps\n        if equation(c) * equation(a) < 0:\n            b = c\n        else:\n            a = c\n    return c\n\n\nif __name__ == \"__main__\":\n    import doctest","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/maths/numerical_analysis/bisection_2.py#L22-L58","documentation":"Error \"Wrong space!\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at maths/numerical_analysis/bisection_2.py:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an interval where the function changes sign (f(a)*f(b) < 0).","Verify the interval bounds are ordered and bracket a 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"}