root: One Dimensional Root (Zero) Finding

View source: R/mesh_set.R

rootR Documentation

One Dimensional Root (Zero) Finding

Description

Search one root with given precision (on y). Iterate over uniroot as long as necessary.

Usage

root(
  f,
  lower,
  upper,
  maxerror_f = 1e-07,
  f_lower = f(lower, ...),
  f_upper = f(upper, ...),
  tol = .Machine$double.eps^0.25,
  convexity = 0,
  ...
)

Arguments

f

the function for which the root is sought.

lower

the lower end point of the interval to be searched.

upper

the upper end point of the interval to be searched.

maxerror_f

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

f_lower

the same as f(lower).

f_upper

the same as f(upper).

tol

the desired accuracy (convergence tolerance on f arg).

convexity

the learned convexity factor of the function, used to reduce the boundaries for uniroot.

...

additional named or unnamed arguments to be passed to f.

Author(s)

Yann Richet, IRSN

Examples

f=function(x) {cat("f");1-exp(x)}; f(root(f,lower=-1,upper=2))
f=function(x) {cat("f");exp(x)-1}; f(root(f,lower=-1,upper=2))

.f = function(x) 1-exp(1*x)
f=function(x) {cat("f");y=.f(x);points(x,y,pch=20,col=rgb(0,0,0,.2));y}
plot(.f,xlim=c(-1,2)); f(root(f,lower=-1,upper=2))

.f = function(x) exp(10*x)-1
f=function(x) {cat("f");y=.f(x);points(x,y,pch=20);y}
plot(.f,xlim=c(-1,2)); f(root(f,lower=-1,upper=2))

.f = function(x) exp(100*x)-1
f=function(x) {cat("f");y=.f(x);points(x,y,pch=20);y}
plot(.f,xlim=c(-1,2)); f(root(f,lower=-1,upper=2))

f=function(x) {cat("f");exp(100*x)-1}; f(root(f,lower=-1,upper=2))

DiceView documentation built on Jan. 17, 2023, 1:09 a.m.