by David J. Wolters
December 29, 2021
This website describes and derives convenient, practical algorithms for solving cubic and quartic equations that have real coefficients. That is, the algorithms find the roots of cubic and quartic polynomials. The algorithms provide:
The documents listed below present the algorithms and provide a tutorial that works out problems and reviews prerequisite mathematics needed to use and derive the algorithms. Click a document title to bring up the document pdf file.
Practical Algorithm for Solving the Cubic Equation
The practical algorithm solves the cubic equation using real-number calculations only. For cubic equations with one real solution, the algorithm modifies Cardano’s formula as suggested by Press,
et al. in Numerical Recipes. This modification avoids Cardano’s relatively large solution error due to round-off for certain cases. The algorithm applies Viète’s trigonometric method for cubic equations with three real solutions.
Practical Algorithms for Solving the Quartic Equation
Five existing algorithms are modified to eliminate their computational shortcomings. The common algorithmic version of Ferrari’s approach and Descartes’s method can become computationally unstable. The National Bureau of Standards (NBS) method is unnecessarily complicated. The method of Euler and that of Van der Waerden and the Digital Library of Mathematical Functions (DLMF) use calculations with complex numbers. Part I of this document presents the five algorithms in both original and modified forms. Notes explain the computational shortcoming of each original algorithm and the fix. Part I ends by tabulating equations to check the validity of the calculated solutions. Part II assesses suitability of the algorithms for general calculation and demonstrates the mathematical equivalence of all the algorithms. Part III derives the algorithms.
Tutorial on Analytic Algorithms to Solve Cubic and Quartic Equations
The tutorial demonstrates the practical algorithm for solving the cubic equation and demonstrates the Ferrari, NBS, and Euler modified algorithms for solving the quartic equation. Appendix A plots example cubic and quartic polynomials to show how the number of real roots is related to the shape of the functional curve. Appendix B provides a review of the mathematics needed to use and derive the algorithms.
Comments and suggestions are welcome. Contact the author at david@quarticequations.com.