Open wnoise opened 1 year ago
I will give it a look this weekend.
For a long time, the finding the root was done using an iterative procedure. A couple of years ago, someone made a pull request and implemented an analytical solution implementing Cardano's algorithm. I really didn't take a deeper look but it worked pretty well and is probably much faster, more accurate and robust than the old iterative procedure.
But I think this uses complex numbers (I haven't studied the implementation) and specifies the type (Float64). I think that both of these points is in conflict with algorithmic differentiation and more specifically ForwardDiff.jl. For my day to day use this is not a issue but it would be really nice to have the package working flawlessly with AD and SciML stuff.
I think we are at a point where we could have something as nice but more flexible and extensible than EES (engineering equation solver)
I will try to study this as soon as possible.
Paulo
Example 1: bigfloats
gives
ForwardDiff also fails:
with
The obvious thing to do is just remove the constraint (and the uses of
T()
inside the function.)This works fine, (including still working with Unitful quantities, as those are dealt with higher up). However examining the function closer,
cardan
is passed information it cannot use, as the last element must always be 1. In addition, ascardan
is not exported, and only calledcalcz
, the second-to-last element is always -1.0, but isn't reflected incardan
.I would recommend:
cardan
to make clear it isn't quite the normal cardano algorithm and only handles cases with 1.0x^3 + ...,