def solveIter(mu,e):
"""__solvIter returns an iterative solution for Ek
Mk = Ek - e sin(Ek)
"""
thisStart = np.asarray(mu-1.01*e)
thisEnd = np.asarray(mu + 1.01*e)
bestGuess = np.zeros(mu.shape)
for i in range(5):
minErr = 10000*np.ones(mu.shape)
for j in range(5):
thisGuess = thisStart + j*(thisEnd-thisStart)/10.0
thisErr = np.asarray(abs(mu - thisGuess + e*np.sin(thisGuess)))
mask = thisErr<minErr
minErr[mask] = thisErr[mask]
bestGuess[mask] = thisGuess[mask]
# reset for next loop
thisRange = thisEnd - thisStart
thisStart = bestGuess - thisRange/10.0
thisEnd = bestGuess + thisRange/10.0
return(bestGuess)
评论列表
文章目录