Learn R Programming

DiceView (version 2.2-0)

roots: One Dimensional Multiple Roots (Zero) Finding

Description

Search multiple roots of 1D function, sampled/splitted by a (1D) mesh

Usage

roots(
  f,
  vectorized = FALSE,
  interval,
  maxerror_f = 1e-07,
  split = "seq",
  split.size = 11,
  tol = .Machine$double.eps^0.25,
  .lapply = parallel::mclapply,
  ...
)

Value

array of x, so f(x)=target

Arguments

f

Function to find roots

vectorized

boolean: is f already vectorized ? (default: FALSE) or if function: vectorized version of f.

interval

bounds to inverse in

maxerror_f

the maximum error on f evaluation (iterates over uniroot to converge).

split

function or "unif" or "seq" (default) to preform interval partition

split.size

number of parts to perform uniroot inside

tol

the desired accuracy (convergence tolerance on f arg).

.lapply

control the loop/vectorization over different roots (defaults to multicore apply).

...

additional named or unnamed arguments to be passed to f.

Examples

Run this code
roots(sin,interval=c(pi/2,5*pi/2))
roots(sin,interval=c(pi/2,1.5*pi/2))

f=function(x)exp(x)-1;
f(roots(f,interval=c(-1,2)))

f=function(x)exp(1000*x)-1;
f(roots(f,interval=c(-1,2)))

Run the code above in your browser using DataLab