11.5: Solution Techniques for Cubic Expressions and Root Finding
 Page ID
 473
Hopefully, we have convinced you that the use of cubic equations of state can represent a very meaningful and advantageous way of modeling the PVT behavior of petroleum fluids. What we need now are the tools that will allow us to get the information that we want out of them. Even though cubic equations of state are explicit in pressure, pressure is not the common unknown to be calculated in the typical problem. In the most common problem, pressure and temperature are known and we want either molar volume (or its reciprocal, molar density) or compressibility factor (the most likely case). Therefore, we are faced very often with the need to solve for the roots of a cubic expression. Here we present a number of approaches that may be followed.
Analytical scheme
Given the cubic polynomial with real coefficients: \(x^3 + ax^2 + bx + c = 0\), the first step is to calculate the parameters:
\[Q=\frac{a^{2}3 b}{9} \label{11.5a}\]
and
\[R=\frac{2 a^{3}9 a b+27 c}{54} \label{11.5b}\]
Now let \(M = R^2 – Q^3\) be the discriminant. We then consider the following cases:

If \(M<0\left(R^{2}<Q^{3}\right)\), the polynomial has three real roots. For this case, compute \(\theta=\arccos \left(\frac{R}{\sqrt{Q^{3}}}\right)\) and calculate the three distinct real roots as:
\[x_{1}=\left(2 \sqrt{Q} \cos \frac{\theta}{3}\right)\frac{a}{3} \label{11.6a}\] \[x_{2}=\left(2 \sqrt{Q} \cos \frac{\theta+2 \pi}{3}\right)\frac{a}{3} \label{11.6b}\] \[x_{3}=\left(2 \sqrt{Q} \cos \frac{\theta2 \pi}{3}\right)\frac{a}{3} \label{11.6c}\]Note that \(x_1\), \(x_2\), \(x_3\) are not given in any special order, and that \(\theta\) has to be calculated in radians.

If \(M>0\left(R^{2}>Q^{3}\right)\), the polynomial has only one real root. Compute:
\[S=\sqrt[3]{R+\sqrt{M}} \label{11.7a}\] \[T=\sqrt[3]{R\sqrt{M}} \label{11.7b}\] and calculate the real root as follows: \[x_{1}=S+T\frac{a}{3} \label{11.7c}\] Two complex roots (complex conjugates) may be found as well. However, they are of no interest for our purposes, and thus no formulas are provided.
Such formulas can be found in the following suggested readings:
 W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery, Numerical Recipes in Fortran, 2^{nd} Edition, Cambridge Univ. Press, (1992), p. 179.
 Spiegel, M., Liu, J., Mathematical handbook of formulas and tables, 2^{nd} Edition, Schaum’s Outline Series, McGraw Hill, p.10.
Sometimes, the equations for \(S\) and \(T\) listed above cause problems while programming. This usually happens whenever the computer/calculator performs the cubic root of a negative quantity. If you want to avoid such a situation, you may compute \(S’\) and \(T’\) instead:
\[S^{\prime}=\operatorname{sign}(R) \sqrt[3]{a b s(R)+\sqrt{M}}\]
\[T^{\prime}=Q / S^{\prime}\]
(making \(T’=0\) when \(S’=0\))
where:
\(abs(R)\) is the Absolute value of \(R\) and \(sign(R)\) is (+1) or (– 1) if \(R\) is positive or negative respectively.
It may be defined as:
\[sign(R) = R/Abs(R)\]
and then the real root is:
\[x_{1}=S^{\prime}+T^{\prime}\frac{a}{3}\]
Keep in mind the following useful relationships among the roots of any cubic expression:
\[x_{1}+x_{2}+x_{3}=a \label{11.8a}\]
\[x_{1} x_{2}+x_{2} x_{3}+x_{3} x_{1}=+b \label{11.8b}\]
\[x_{1} x_{2} x_{3}=c \label{11.8c}\]
Test your understanding of cubic root calculations by analytical means by solving the following examples.
Exercise \(\PageIndex{1}\)
With general cubic expressions,
\[\begin{aligned}
&x^{3}6 x^{2}+11 x6=0 \Rightarrow\\
&x_{1}=1\\
&x_{2}=2\\
&x_{3}=3
\end{aligned}\]
\[\begin{aligned}
&x^{3}+7 x^{2}+49 x+343=0\\
&x_{1}=7\\
&x_{2}=0+7 i\\
&x_{3}=07 i
\end{aligned}\]
\[\begin{aligned}
&x^{3}+2 x^{2}+3 x+4=0 \Rightarrow\\
&x_{1}=1.65063\\
&x_{2}=0.174685+1.54687 i\\
&x_{3}=0.1746851.54687 i
\end{aligned}\]
with EOS in terms of volume (\(v\)), for a pure component,
\[v^{3}7.8693 v^{2}+13.3771 v6.5354=0 \nonumber\]
Only one real root (one phase) with
\[v_{1}=5.7357 \nonumber\]
Exercise \(\PageIndex{2}\)
\[v^{3}15.6368 v^{2}+30.315 v14.8104=0\]
Solution
Two possible phases (three real roots),
\[\begin{aligned}
&v_{1}=0.807582 \text { (liquid phase) }\\
&v_{2}=1.36174 \text { (rejected) }\\
&v_{3}=13.4675 \text { (gas phase) }
\end{aligned}\]
with EOS in terms of the compressibility factor (z), for a pure component,
\[z^{3}1.0595 z^{2}+0.2215 z0.01317=0 \nonumber\]
=> One phase:
\[z=0.8045 \nonumber\]
Exercise \(\PageIndex{2}\)
\[z^{3}z^{2}+0.089 z0.0013=0\]
Solution
Two possible phases,
\[\begin{aligned}
&z_{\text {liquid}}=0.0183012\\
&z_{x}=0.0786609 \text { (useless) }\\
&\mathrm{Z}_{\mathrm{vapor}}=0.903038
\end{aligned}\]
Numerical Scheme
The NewtonRaphson method provides a useful scheme for solving for a nonexplicit variable from any form of equation (not only cubic ones). NewtonRaphson is an iterative procedure with a fast convergence, although it is not always capable of providing an answer — because a first guess close enough to the actual answer must be provided.
In solving for “x” in any equation of the type f(x)=0, the method provides a new estimate (new guess) closer to the actual answer, based on the previous estimate (old guess). This is written as follows:
\[x_{n e w}=x_{o l d}\frac{f\left(x_{o l d}\right)}{f^{\prime}\left(x_{o l d}\right)} \label{11.9}\]
Considering a cubic equation \(f(x)=x^{3}+a x^{2}+b x+c=0\), the previous equation takes the form:
\[x_{n e w}=x_{o l d}\frac{x_{o l d}^{3}+a x_{o l d}^{2}+b x_{o l d}+c}{3 x_{o l d}^{2}+2 a x_{o l d}+b} \label{11.10}\]
The iterations continue until no significant improvement for “\(x_{new}\)” is achieved, i.e., \( x_{new} – x_{old} \) < tolerance. An educated guess must be provided as the starting value for the iterations. If you are solving a cubic equation in Z (compressibility factor), it is usually recommend to take \(Z = bP/RT\) as the starting guess for the compressibility of the liquid phase and \(Z = 1\) for the vapor root.
Semianalytical Scheme
If you used the previous numerical approach to calculate one of the roots of the cubic expression, the semianalytical scheme can give you the other two real roots (when they exist). By using the relationships given before, with the value ‘x_{1}’ as the root already known, the other two roots are calculated by solving the system of equations:
\[x_{2}+x_{3}=ax_{1} \label{11.11a}\]
\[x_{2} x_{3}=c / x_{1} \label{11.11b}\]
which leads to a quadratic expression.
This procedure can be reduced to the following steps:

Let \(x^3 + ax^2 + bx + c = 0\) be the original cubic polynomial and “\(E\)” the root which is already known (\(x_1 = E\)). Then, we may factorize such a cubic expression as: \[(xE)\left(x^{2}+F x+G\right)=0 \label{11.12a}\] where \[F = a + E \label{11.12b}\] \[G = – c / E \label{11.12c}\]

Solve for \(x_2\), \(x_3\) by using the quadratic equation formulae,
\[x_1 = E \label{11.13a}\] \[x_{2}=\frac{F+\sqrt{F^{2}4 G}}{2} \label{11.13b}\] \[x_{3}=\frac{F\sqrt{F^{2}4 G}}{2} \label{11.13c}\]
Contributors
Prof. Michael Adewumi (The Pennsylvania State University). Some or all of the content of this module was taken from Penn State's College of Earth and Mineral Sciences' OER Initiative.