bisection.root: Find zero of a function by bracketing the zero and then using...

Description Usage Arguments Value Author(s)

View source: R/solve-irr.R

Description

Tries to find the zero of a function by using the bisection method (uniroot). To call uniroot, the zero must be bracketed by finding two points at which the function value has opposite signs. The main code in this function is a grid search to find such a pair of points. A geometric grid of points between lower and guess and also between guess and upper. This grid is searched for two neighbouring points across which the function changes sign. This brackets the root, and then we try to locate the root by calling uniroot

Usage

1
bisection.root(f, guess, lower, upper, nstep = 100, toler = 1e-06)

Arguments

f

The function whose zero is to be found. An R function object that takes one numeric argument and returns a numeric value. In an IRR application, this will be the NPV function. In an implied volatility application, the value will be the option price.

guess

The starting value (guess) from which the solver starts searching for the root. Must be positive.

lower

The lower end of the interval within which to search for the root. Must be positive.

upper

The upper end of the interval within which to search for the root. Must be positive.

nstep

The number of steps in the grid search to bracket the zero. See details.

toler

The criterion to determine whether a zero has been found. This is passed on to uniroot

Value

The root (or NA if the method fails)

Author(s)

Prof. Jayanth R. Varma


jrvFinance documentation built on Nov. 5, 2021, 5:07 p.m.