# Define the rate equation:
quarantine_eq <- c(
dSdt ~ -k * S * I,
dIdt ~ k * S * I - beta * I
)
# Define the parameters (as a named vector):
quarantine_parameters <- c(k = .05, beta = .2)
# Define the initial condition (as a named vector):
quarantine_init <- c(S = 300, I = 1)
# Define deltaT and the number of time steps:
deltaT <- .1 # timestep length
n_steps <- 10 # must be a number greater than 1
# Compute the solution via Euler's method:
out_solution <- rk4(system_eq = quarantine_eq,
parameters = quarantine_parameters,
initial_condition = quarantine_init, deltaT = deltaT,
n_steps = n_steps
)
Run the code above in your browser using DataLab