begin public runge_kutta use math.na: pli function runge_kutta_first_order(argm) {f, h=0.001, w=10, unilateral=false} = argm x0 = argm["t0"] y0 = argm["y0"] N = int(w/abs(h))+1 x=x0; y=y0 a = [y] for k in 1..N k1 = f(x,y) k2 = f(x+0.5*h,y+0.5*h*k1) k3 = f(x+0.5*h,y+0.5*h*k2) k4 = f(x+h,y+h*k3) y = y+h/6*(k1+2*(k2+k3)+k4) x = x0+k*h a.push(y) end if unilateral return pli(x0,h,a) end x=x0; y=y0 b = [y] for k in 1..N k1 = f(x,y) k2 = f(x-0.5*h,y-0.5*h*k1) k3 = f(x-0.5*h,y-0.5*h*k2) k4 = f(x-h,y-h*k3) y = y-h/6*(k1+2*(k2+k3)+k4) x = x0-k*h b.push(y) end fp = pli(x0,h,a) fm = pli(x0,-h,b) return |x| fm(x) if x