There are many scenarios where one wants to find the roots of an algebraic expression (e.g. calculating the implied volatility of an option). However, sometimes it is very difficult (if not impossible) to find a closed form solution to a given expression, e.g. solve for x: . This is where iterative methods such as Newton’s method come in.

An iterative method is simply a method that begins with a fixed value, and by plugging that fixed value into the method, we are able to calculate the next value. Doing this over and over again, the method converges to the solution to the equation. Hence the name *iterative* method.

Newton’s method, is one such method, and works the following way: suppose we have some function and we are trying to find such that (i.e. we want to find the root of the function). We can start with some guess , draw the tangent line to the curve at the point . Now, where the tangent line crosses the x-axis is our next guess , and we repeat (see the animation for a depiction of how this converges to a root).

The equation of Newton’s method is: .

Animation of Newton method (Photo credit: Wikipedia)

It is easy to see that one obvious downfall of Newton’s method is that you must be able to differentiate the function that you are using. One way to get around this would be to use the Secant method which works very similarly to Newton’s method, but does not require the function to be differentiable.

In order to implement Newton’s method, we need an initial guess (which is of course dependent on the function) and a given tolerance that we should stop within (since this is a convergent method, it would need to loop infinitely for an exact solution).

double newtons_method(double x_0, double tol){
// It is assumed that f() and f_prime() are
// functions that are elsewhere declared
// declare and initiate parameters
double x_new = x_0;
double x_old = x_0 - 1;
// now we perform the iterative Newton's method
do{
x_old = x_new; // store the old x value
x_new = x_old - f(x_old)/f_prime(x_old); // calculate the new x value
}while(fabs(x_old - x_new) > tol); // loop until within the given tolerance
return x_new;
}

Using the above code with an implemented Black-Scholes model, we would be able to calculate the implied volatility of an option by setting the function , where is the BS value of the option for a given volatility , is the market price of the option, and refers to the Vega of the option.