find_roots | R Documentation |
Root-finding algorithm using sliding windows to numerically find the roots of a function within a range.
find_roots(f, from, to, n = 10, size = 1, precis = NULL, ...)
f |
The function whose roots to find (must have one argument only) |
from, to |
The bounds of the range of values to explore |
n |
The number of bins in which to split the range |
size |
The size of the sliding window, in number of bins |
precis |
To what precision digit to round the solutions (no rounding if
|
... |
Additional arguments to be passed to |
The function numerically looks for one root within each window, then
removes duplicate solutions and returns the output. Sometimes duplicate
solutions may not be recognized as such because they differ by a negligible
amount. Use the precis
argument to round those solutions to a lower
precision (done using round
) and recognize them as duplicates.
A vector of solutions
get_sliding_windows
, uniroot_noerr
f <- function(x) x^2 - 1
find_roots(f, -10, 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.