library(deSolve) ball <- function(t, y, parms) { dy1 <- y[2] dy2 <- -9.8 list(c(velocity=dy1, acc=dy2)) } #yini <- c(height = 0, velocity = 10) #rootfunc <- function(t, y, parms) return (y[1]) # # #eventfunc <- function(t, y, parms) { # y[1] <- 0 # y[2] <- -0.9*y[2] # return(y) #} # times <- seq(from = 0, to = 20, by = 0.01) out <- ode(times = times, y = c(0,10), func = ball,parms = NULL #,rootfun = rootfunc,events = list(func = eventfunc, root = TRUE) ) head(out)