times = c(0,0.4*10^(0:10))
y = c(1,0,0)
func = function(t,y,parms,b=-0.04E0) {
ydot = rep(0,3)
ydot[1] = parms$a * y[2] * y[3] + b * y[1]
ydot[3] = 3.0E7 * y[2] * y[2]
ydot[2] = -1.0 * (ydot[1] + ydot[3])
list(ydot, sum(y))
}
lsoda::ode(y, times, func, parms=list(a=1.0E4), rtol=1e-8, atol=1e-8)
Run the code above in your browser using DataLab