We can plot both ($y = x^2$ (blue) and $y = x^3-2x+1$ (magenta)) functions as:
This shows three points of intersection.
We can then set each function equal to each other and write the combined function to find the roots of (notice the cubic, hence three roots):
$$ f(x) = x^3 - x^2 - 2 x + 1 = 0$$
A plot of this shows:
We can pick three ranges, each of which contains a root, and use the Bisection Method to find that root:
- $x \in [-2,-1] \rightarrow x = -1.2469796037174670611$
- $x \in [0,1] \rightarrow x = 0.44504186791262880858$
- $x \in [1,2] \rightarrow x = 1.8019377358048382525$
Do you know why each range is guaranteed to find a root using the Bisection Method? Can you make those ranges larger? Smaller? Randomly? What about choosing the range to be $x \in [-2,2]$ (that range contains all three roots, so what happens with the algorithm)?