The function newton.raphson.root
is a general root finder which
can find the zero of any function whose derivative is available.
In this package, it is called by irr.solve
and by
GenBSImplied
. It can be used in other situations as
well - see the examples below.
newton.raphson.root(
f,
guess = 0,
lower = -Inf,
upper = Inf,
max.iter = 100,
toler = 1e-06,
convergence = 1e-08
)
The function whose zero is to be found. An R function object that takes one numeric argument and returns a list of two components (value and gradient). In an IRR application, these two components will be the NPV and the DV01/10000. In an implied volatility application, the components will be the option price and the vega. See also the examples below
The starting value (guess) from which the solver starts searching for the IRR
The lower end of the interval within which to search for the root
The upper end of the interval within which to search for the root
The maximum number of iterations of the Newton-Raphson procedure
The criterion to determine whether a zero has been
found. If the value of the function exceeds toler
in
absolute value, then NA
is returned with a warning
The relative tolerance threshold used to
determine whether the Newton-Raphson procedure has
converged. The procedure terminates when the last step is less
than convergence
times the current estimate of the
root. Convergence can take place to a non zero local
minimum. This is checked using the toler
criterion
below
The function returns NA
under either of two conditions: (a)
the procedure did not converge after max.iter
iterations,
or (b) the procedure converged but the function value is not zero
within the limits of toler
at this point. The second
condition usually implies that the procedure has converged to a
non zero local minimum from which there is no downhill gradient.
If the iterations converge to a genuine root (within the limits of
toler
), then it returns the root that was found.
The Newton Raphson solver was converted from C++ code in the Boost library