## Not run: ------------------------------------
# # Logistic growth
# compile_sys("logistic", "dxdt = x * (1 - x)")
# plot(logistic(0.001, 15, 0.1), type = "l", lwd = 2, col = "steelblue")
# Sys.sleep(0.5)
#
# # Lotka-Volterra predator-prey equations
# pars = c(alpha = 1, beta = 1, gamma = 1, delta = 1)
# LV.sys = '
# dxdt[0] = alpha * x[0] - beta * x[0] * x[1];
# dxdt[1] = gamma * x[0] * x[1] - delta * x[1];
# ' # LV.sys
# compile_sys("preypred", LV.sys, pars, TRUE)
# x = preypred(rep(2, 2), 100, 0.01)
# plot(x[, 2:3], type = "l", lwd = 2,
# xlab = "Prey", ylab = "Predator",
# col = "steelblue")
# Sys.sleep(0.5)
#
# # Lorenz model from odeint examples
# pars = c(sigma = 10, R = 28, b = 8 / 3)
# Lorenz.sys = '
# dxdt[0] = sigma * (x[1] - x[0]);
# dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
# dxdt[2] = -b * x[2] + x[0] * x[1];
# ' # Lorenz.sys
# compile_sys("lorenz", Lorenz.sys, pars, TRUE)
# x = lorenz(rep(1, 3), 100, 0.001)
# plot(x[, c(2, 4)], type = 'l', col = "steelblue")
## ---------------------------------------------
Run the code above in your browser using DataLab