Newton Raphson Method - nullstar/SecondBrain GitHub Wiki
The Newton-Raphson method (also known as Newton's method) is a way to quickly find a good approximation for the root of a real-valued function $f(x) = 0$. It uses the idea that a continuous and differentiable function can be approximated by a straight line tangent to it.
Suppose you need to find the root of a continuous, differentiable function $f(x)$, and you know the root you are looking for is near the point $x = x_0$. Then Newton's method tells us that a better approximation for the root is
Note: the term "near" is used loosely because it does not need a precise definition in this context. However, $x_0$ should be closer to the root you need than to any other root (if the function has multiple roots)
One example where this method is used is to estimate the eccentric anomaly
If we wish to estimate the value of
Next we calculate the derivative of this equation which is:
Then we can use the following code which implements Newton Raphson Method to estimate
float E = M;
constexpr float tolerance = 0.001f;
while (true)
{
const float prevE = E;
E = E - (E - e * sinf(E) - M) / (1.0f - e * cosf(E));
if (fabsf(E - prevE) < tolerance)
break;
}
Newton's method may not work if there are points of inflection, local maxima or minima around $x_0$ or the root.
In situations like this, it will help to get an even closer starting point, where these critical points will not interfere.
#Math #Solver