# S.O.S. Mathematics CyberBoard

Your Resource for mathematics help on the web!
 It is currently Fri, 24 May 2013 17:38:34 UTC

 All times are UTC [ DST ]

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: 100% Robust Cubic Equation SolverPosted: Wed, 31 Aug 2011 22:38:28 UTC
 S.O.S. Newbie

Joined: Wed, 31 Aug 2011 22:27:30 UTC
Posts: 1
Hi all,

I need to write an algorithm which finds the real roots to a cubic equation.

I am applying a cubic equation of state to a chemical engineering problem, and a specific cubic equation needs to be solved thousands of times over the course of one routine.

Therefore it needs to be COMPLETELY robust, and here's where my problem lies.

It seems analytical methods are prone to errors due to the floating point precision of computers, and I am tending towards several numerical approximation methods (Newton-Raphson, Halley's method, Brent's Method). The problems are:

Newton-Raphson / Halley's - Not sure whether these will be guaranteed to converge, they may diverge if the initial guess is not good enough (which it may well not be)

Brent's Method - although convergence is guaranteed, I am unsure of how to bracket the roots and whether it will be affected by the presence of complex roots.

ANy help or pointers much appreciated. As I say I am not simply trying to solve a cubic equation (fairly easy) but write a code which will NEVER fail no matter what values are used. Thanks.

Top

 Post subject: Re: 100% Robust Cubic Equation SolverPosted: Thu, 1 Sep 2011 05:28:39 UTC
 Moderator

Joined: Mon, 29 Dec 2008 17:49:32 UTC
Posts: 6009
Location: 127.0.0.1, ::1 (avatar courtesy of UDN)
Hi all,

I need to write an algorithm which finds the real roots to a cubic equation.

I am applying a cubic equation of state to a chemical engineering problem, and a specific cubic equation needs to be solved thousands of times over the course of one routine.

Therefore it needs to be COMPLETELY robust, and here's where my problem lies.

It seems analytical methods are prone to errors due to the floating point precision of computers, and I am tending towards several numerical approximation methods (Newton-Raphson, Halley's method, Brent's Method). The problems are:

Newton-Raphson / Halley's - Not sure whether these will be guaranteed to converge, they may diverge if the initial guess is not good enough (which it may well not be)

Brent's Method - although convergence is guaranteed, I am unsure of how to bracket the roots and whether it will be affected by the presence of complex roots.

ANy help or pointers much appreciated. As I say I am not simply trying to solve a cubic equation (fairly easy) but write a code which will NEVER fail no matter what values are used. Thanks.

If you want it to be completely robust, you need to split it into cases. For real coefficients, at the very least you will have three cases to consider, according to the sign of the discriminant, and make sure you avoid subtracting nearly equal quantities in the intermediate calculations.

_________________

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 2 posts ]

 All times are UTC [ DST ]

#### Who is online

Users browsing this forum: No registered users

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ High School and College Mathematics    Algebra    Geometry and Trigonometry    Calculus    Matrix Algebra    Differential Equations    Probability and Statistics    Proposed Problems Applications    Physics, Chemistry, Engineering, etc.    Computer Science    Math for Business and Economics Advanced Mathematics    Foundations    Algebra and Number Theory    Analysis and Topology    Applied Mathematics    Other Topics in Advanced Mathematics Other Topics    Administrator Announcements    Comments and Suggestions for S.O.S. Math    Posting Math Formulas with LaTeX    Miscellaneous