MATLAB Answers

Increase arithmetic precision in using Cardano formula

23 views (last 30 days)
Ahmad Sheikhzada
Ahmad Sheikhzada on 23 Sep 2021 at 21:49
Commented: Ahmad Sheikhzada on 24 Sep 2021 at 15:31
I am using general analytic formula to find the roots of a quartic equation as shown here. The equation is of general form with variable complex coefficients, so very small chance to reduce it to a simpler form. Within the arithmetic I lose lots of precision specially when coefficients take on small values. I used symbolic toolbox and vpa and got fantastic result but it is very time-consuming and almost impossible to use in my case as solving this quartic equation is done in each time step integration of solving an ODE problem.
Any idea or a numerical trick to circumvent this issue?
Thanks,

Answers (1)

John D'Errico
John D'Errico on 23 Sep 2021 at 22:55
Edited: John D'Errico on 23 Sep 2021 at 22:57
Either use roots to solve for the roots of the quartic, or be forced to use symbolic form for the solutions. Note that roots will be blazingly fast, and it will give you virtually full double precision accuracy. The only case where roots will not be full double precision accuracy is when there are roots with higher multiplicity than 1, but that is not the fault of roots.
Note, there is absolutely no need to use the Cardano formula, as roots will be just as accurate and probably as fast.
If you find the numerical roots from roots are insufficiently accurate, then you have no choice but to use higher precision, and accept that if you insist on super high accuracy, then you must sacrifice speed.
There is no solution that will be both immensely accurate AND blazingly fast. So take your pick. There are no "tricks".
  1 Comment
Ahmad Sheikhzada
Ahmad Sheikhzada on 24 Sep 2021 at 15:31
Thanks John...
First, I am not sure how roots might be more or even as efficient here since it only accepts a vector containing the coefficients of the polynomial. So, if the roots is being calculated for a polynomial with variable coefficients (root as a continous function of coefficients) - which is the case here- then we have to use a for loop, while with Cardano formula it can be done easily without a for loop.
Second, how can we choose a particular root among four? Using Cardano you pick only one formula out of four.
Thanks again for your time...

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!