[PATCH] Analytic solution rather than binary root search
Jan Darowski
jan.darowski at gmail.com
Wed Jul 1 12:29:18 PDT 2015
Cool, thanks for doing that. For tomorrow I'm planning bigger tests
and the commits refactor so I can immediately check the results of
this patch. Also, something similar is used in the Boyles compensation
(the same situation: Newton's method in the original) so maybe this
will solve two problems at once.
2015-07-01 12:38 GMT+02:00 Robert Helling <helling at lmu.de>:
> 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
>
>
>
>
>
>
--
Jan Darowski
More information about the subsurface
mailing list