22. Bisection root-finding

Finding roots by using bisection is relatively straightforward, although there are a couple of tricky details. One of the most important is realizing that it's not always obvious what interval to use when looking for a root.

For example, if the function's value at the interval's endpoints, x0 and x1, are both positive or both negative, then the interval may contain no roots, one root, or several roots. The following diagram shows three functions. All three start and end with function values greater than zero. The curve on the left has no roots because it does not cross the X axis, the middle curve has a single root where it touches the X axis, and the curve on the right has four roots because it crosses the X axis ...

Get The Modern C# Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.