TheAlgorithms/Python · error · ValueError
Wrong space!
Error message
Wrong space!
What it means
Error "Wrong space!" thrown in TheAlgorithms/Python.
Source
Thrown at maths/numerical_analysis/bisection_2.py:40
9.99
"""
return 10 - x * x
def bisection(a: float, b: float) -> float:
"""
>>> bisection(-2, 5)
3.1611328125
>>> bisection(0, 6)
3.158203125
>>> bisection(2, 3)
Traceback (most recent call last):
...
ValueError: Wrong space!
"""
# Bolzano theory in order to find if there is a root between a and b
if equation(a) * equation(b) >= 0:
raise ValueError("Wrong space!")
c = a
while (b - a) >= 0.01:
# Find middle point
c = (a + b) / 2
# Check if middle point is root
if equation(c) == 0.0:
break
# Decide the side to repeat the steps
if equation(c) * equation(a) < 0:
b = c
else:
a = c
return c
if __name__ == "__main__":
import doctestView on GitHub (pinned to f5988cc097)
Solutions
- Pass an interval where the function changes sign (f(a)*f(b) < 0).
- Verify the interval bounds are ordered and bracket a root.
When it happens
Trigger: Thrown at maths/numerical_analysis/bisection_2.py:40 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of TheAlgorithms/Python@f5988cc097 (2026-08-14).
Data as JSON: /api/errors/28953f1097f76a6c.
Report an issue: GitHub.