<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">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).</div><div class=""><br class=""></div><div class="">Best</div><div class="">Robert</div><div class=""></div></body></html>