Solving two very simple first differential equations

Look at this example: https://diffeq.sciml.ai/stable/tutorials/ode_example/#Defining-Parameterized-Functions

using Plots, DifferentialEquations
function lorentz!(du,u,p,t)
I, V = u
R, L, C, a = p
du[1] = dI = -(R/L)*I-(1/L)*V+(1/L)*a
du[2] = dV = (1/C)*I
end
u0 = [0,0];
tspan = (0.0,10)
p = [0.1, 0.01, 0.001, 1.0]
prob = ODEProblem(lorentz!,u0,tspan,p)
sol = solve(prob)
gr()
plot(sol,vars=(0,1),xlim=(0,1))

1 Like