Iterate | R Documentation |
Iterates a function a specified number of times on an initial condition.
Iterate(f = NULL, A = NULL, x0 = 0, n = 10, fargs = list())
f |
a function of one or more state variables which returns a vector containing
those same state variables. Parameters to |
A |
As an alternative to |
x0 |
a vector with the numerical initial condition. There should be 1 component
in |
n |
an integer specifying the number of iterations |
fargs |
list containing values for numerical parameters to the function |
The function f
can take one or more arguments. The first of these
should represent the state of the dynamical system, e.g. x, or x and y, etc.
At the end of the argument list to f
can come named parameters. The length of the
initial condition x0
must match the number of state arguments. Numerical values for
parameters (if any) must be provided in the ...
slot.
A data frame with a column .i
listing the iteration number
and columns for each component of the initial condition. There will be n+1
rows, the first for the initial condition and the remaining for the n iterations.
Iterate(function(x, mu=3.5) mu*x*(1-x), x0=.232, n=10, list(mu=4)) # chaos
Iterate(function(x, y) c(x+y, x-y), x0 = c(1,1), n=10)
Iterate(function(x, y) c(x+y, x), x0=c(1,0), n=10) # fibonacci
Iterate(A = cbind(rbind(1, 1), rbind(1, 0)), x0=c(1,0), n=5) # fibonacci described by a matrix
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.