I have the following simple solution to the Kepler's equation which uses newton-rhapson iterative technique. I have read various papers about the initial guess and divergence near an eccentricty of 1, but I run the following test code and never get any divergent solutions. Am I missing something or does this solution always converge?
The following is a matlab script with a helper function:
n = 1e6; FM = rand(n,1)*2*pi; ECC = rand(n,1)*.9999999; ecan = zeros(n,1); E = zeros(n,1); tic for i = 1:n [E(i)] = kepler(FM(i),ECC(i)); end toc close all plot(E - FM - ECC.*sin(E)); %kepler solves kepler equation for conversion from mean to eccentric %anomaly using newton-rhapson itteration function [E] = kepler(M,ecc) %Tolerance for function eps = 1e-8; %Set initial guess En = M; Ens = En - (En - ecc*sin(En)- M)/(1 - ecc*cos(En)); % begin itteration (newton-rhapson) while (abs(Ens-En) > eps) En = Ens; Ens = En - (En - ecc*sin(En) - M)/(1 - ecc*cos(En)); end E = Ens; end