Root finding

GUIDING QUESTION: How can I compute a solution to an equation?
Given a function $f$, how can I find $x$ such that $f(x) = 0$?


A root or a zero of a function $f$ is an element $x$ in the domain of $f$ such that $f(x) = 0$.
In general $f$ could be a vector-valued function of multiple variables but for now we'll focus on scalar-valued functions of a single variable. That is, $$f: \mathbb{R} \to \mathbb{R}.$$ We'll consider the genral case in a few weeks.

Motivation

(Vander Waals equations) Recall the ideal gas law $PV=nRT$ used to model ideal gases. Real gases are in fact not fully compressible and there are attractive forces pulling their molecules together, so the Van der Waals equation \begin{equation} \big(P + \frac{n^2 a}{V^2}\big) \big(V-nb\big)=nRT, \end{equation} where $a$ and $b$ are correction terms, is a better model for the behavior of real gases. In a lab, suppose $1$ mol of chlorine gas has a pressure of $2$ atm and a temperature of $313K$, for chlorine, $a= 6.29$ atm $L^2/\mathrm{mol}^2, b=0.0562 L/ \mathrm{mol}$.

How would you find the volume $V$?

We can't just “isolate” $V$ to find the exact solution. We turn to numerical methods to approximate a solution.

(Granted, in this case rearranging yields a low-degree polynomial in $V$, and the cubic formula would suffice.)