by David J. Wolters
October 4, 2025
This website describes and derives convenient, practical algorithms for solving cubic and quartic equations with real coefficients. Additional algorithms mitigate computer round-off error in the solutions. 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 Algorithms 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. The five algorithms are provided in both original and modified forms. Notes explain the computational shortcoming of each original algorithm and the fix.
Round-Off Error Mitigation In Solving Cubic and Quartic Equations
This document provides analytic techniques to mitigate round-off error which becomes magnified when 1) two or more solutions equal the same real value (multiplicity), and/or 2) absolute values of two or more solutions differ from each other by many orders of magnitude, and/or 3) a quartic polynomial is symmetric about some argument. The mitigation design also addresses equations with solutions nearly equal to the same value and quartic polynomials that are nearly symmetric.
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.