Description Usage Arguments Details Value Author(s) References See Also Examples

Bracket the zeros (roots) of a univariate function

1 2 3 4 5 |

`fun` |
a univariate function; it will be called as |

`interval` |
a numeric vector, containing the end-points of the interval to be searched |

`...` |
further arguments passed to |

`lower` |
lower end-point. Ignored if |

`upper` |
upper end-point. Ignored if |

`n` |
the number of function evaluations. Must be at least 2 (in which
case |

`method` |
can be |

`mc.control` |
a list containing settings that will be passed to |

`cl` |
default is |

`bracketing`

evaluates `fun`

at equal-spaced values of `x`

between (and including) `lower`

and `upper`

. If the sign of
`fun`

changes between two consecutive `x`

-values,
`bracketing`

reports these two `x`

-values as containing (‘bracketing’)
a root. There is no guarantee that there is only one root
within a reported interval. `bracketing`

will not narrow the chosen intervals.

The argument `method`

determines how `fun`

is
evaluated. Default is `loop`

. If `method`

is
`"vectorised"`

, `fun`

must be written such that it can be
evaluated for a vector `x`

(see Examples). If `method`

is
`multicore`

, function `mclapply`

from package parallel
is used. Further settings for `mclapply`

can be passed through
the list `mc.control`

. If `multicore`

is chosen but the
functionality is not available (eg, currently on Windows), then
`method`

will be set to `loop`

and a warning is issued. If
`method`

is `snow`

, function `clusterApply`

from
package parallel is used. In this case, the argument `cl`

must either be a cluster object (see the documentation of
`clusterApply`

) or an integer. If an integer, a cluster will be
set up via `makeCluster(c(rep("localhost", cl)), type = "SOCK")`

,
and `stopCluster`

is called when the function is exited. If
`snow`

is chosen but the package is not available or `cl`

is
not specified, then `method`

will be set to `loop`

and a
warning is issued. In case that `cl`

is a cluster object,
`stopCluster`

will not be called automatically.

A numeric matrix with two columns, named *lower* and
*upper*. Each row contains one interval
that contains at least one root. If no roots were found, the matrix
has zero rows.

Enrico Schumann

Gilli, M., Maringer, D. and Schumann, E. (2011) *Numerical
Methods and Optimization in Finance*. Elsevier.
http://www.elsevierdirect.com/product.jsp?isbn=9780123756626

Schumann, E. (2016) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual

`uniroot`

(in package stats)

1 2 3 4 5 6 | ```
## Gilli/Maringer/Schumann (2011), p. 290
testFun <- function(x)
cos(1/x^2)
bracketing(testFun, interval = c(0.3, 0.9), n = 26L)
bracketing(testFun, interval = c(0.3, 0.9), n = 26L, method = "vectorised")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.