ericagol / NbodyGradient.jl

N-body integrator computes derivatives with respect to initial conditions for TTVs, RV, Photodynamics & more
MIT License
20 stars 9 forks source link

Stability and speed of cube root #38

Closed ericagol closed 3 years ago

ericagol commented 3 years ago

The term: A = -sign(R)cbrt(abs(R) + sqrt(RR - QQQ))

can have a cancellation between a^6/729 and a^4b/81 in the expansion of R^2 and Q^3. Perhaps making these cancellations analytically will make this more stable to evaluate (although maybe this doesn't matter since these are added to |R|).

Also, this is a time-consuming line of code, so it would be nice to find a faster expression to evaluate.