Find the root of a monotone function on a discrete grid of value using dichotomic search
discreteRoot(
fn,
grid,
increasing = TRUE,
check = TRUE,
tol = .Machine$double.eps^0.5
)
[function] objective function to minimize in absolute value.
[vector] possible minimizers.
[logical] is the function fn increasing?
[logical] should the program check that fn takes a different sign for the first vs. the last value of the grid?
[numeric] the absolute convergence tolerance.