MATLAB Answers

Increase arithmetic precision in using Cardano formula

조회 수: 23(최근 30일)
Ahmad Sheikhzada
Ahmad Sheikhzada 2021년 9월 23일 21:49
댓글: Ahmad Sheikhzada 2021년 9월 24일 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?


John D'Errico
John D'Errico 2021년 9월 23일 22:55
편집: John D'Errico 2021년 9월 23일 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
Ahmad Sheikhzada
Ahmad Sheikhzada 2021년 9월 24일 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...

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by