[PATCH] Analytic solution rather than binary root search

Robert Helling helling at lmu.de
Wed Jul 1 03:38:19 PDT 2015


Hi,

here is a patch to be applied on top of Jan’s patches (maybe Jan can integrate it in his change set) to compute the root of a cubic equation analytically rather than doing an expensive binary search.

It contains some assumption on the parameter values encountered that holds in the cases I tried. There is an error reported if that assumption does not hold (to be more specific: the general cubic has three solutions in the complex plane for which at least one of is real for real coefficients. Mathematica gives formulas for all three of them but I took only the one that happened to be real in my trials. A safer approach would be to compute all three of them with complex arithmetic and then take the one with the smallest imaginary part. That would be far more expensive to compute and  I am quite optimistic it would be overkill. In any case there might after all be three real solutions in which case also the binary search returns a random one).

Best
Robert


--
.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oO
Robert C. Helling     Elite Master Course Theoretical and Mathematical Physics
                      Scientific Coordinator
                      Ludwig Maximilians Universitaet Muenchen, Dept. Physik
                      Phone: +49 89 2180-4523  Theresienstr. 39, rm. B339
                      http://www.atdotde.de

Enhance your privacy, use cryptography! My PGP keys have fingerprints
A9D1 A01D 13A5 31FA 6515  BB44 0820 367C 36BC 0C1D    and
DCED 37B6 251C 7861 270D  5613 95C7 9D32 9A8D 9B8F





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150701/18d3a3df/attachment-0002.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Use-an-analytic-solution-for-nucleon-inner-pressure-in.txt
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150701/18d3a3df/attachment-0001.txt>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150701/18d3a3df/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150701/18d3a3df/attachment-0001.sig>


More information about the subsurface mailing list