Closed ericagol closed 1 year ago
It appears that the initial guess is within the time step, but then Newton's method causes the times to go out of the timestep. The cause appears to be that the g
function becomes larger than the initial time step boundaries, rather than getting smaller. So, perhaps a hybrid finder, such as a bracketing followed by Newton's, or Brent's method, would fix this.
A couple of options I am thinking of:
@langfzac I found the problem. This initial guess should be found by interpolation from the current time (where the "prior" state is saved), and then integrated backwards. But, the current formula is assuming that the integration is forwards in time:
Working through the interpolation, this formula should look like:
dt0 = -gi*intr.h/(gi-tt.gsave[i]) # Starting estimate
i.e. tt.gsave[i]
in the numerator should be gi
instead. When I fix this, it fixes the outlier issue, as well as the other problems we were finding before!
So, all to say, I think Newton's method works fine, and it was only because the starting guess was wrong that caused a problem with convergence and the occasional outlier. The only thing I'm puzzled about is why we didn't catch this before when we were checking the code... I thought we put in a temporary check that the interpolated initial guess was negative, and was greater than one time step before (i.e. between -h and 0). If we fix this, the code should run a bit faster since it will start much closer to the transit-time!
For some initial orbital elements, the transit times show outliers.
Here is a minimum working example (this error occurs in Julia v1.7.2):
If I rerun with a slightly different integration time, the error disappears:
But, decreasing changing h by a smaller factor, the outlier remains: