bisect | R Documentation |
provides recursive bisection algorithm for
an arbitrary function
It evaluates the function foo
at the bounds and
replaces one of the boundaries until a maximum is found
or the interval becomes too small
bisect(foo, bounds, known = NULL, ..., tolx = 5, toly = 0.01)
foo |
a function mapping a one-dim argument to one-dim value |
bounds |
a vector of length 2 with real valued numbers
(i.e. two arguments of |
known |
tells for which of the arguments a value is known (defaults to NULL) |
... |
additional parameters for |
tolx |
break condition for argument (defaults to 10) |
toly |
break condition for value (defaults to 0.01) |
A range of bounds where foo
is maximal.
get_maximum <- bisect(function(x){-(x-2)^2}, c(-5,50))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.