Seven Lines of Julia (examples sought)

Julia code for the Lorenz problem provided in Wikipedia that uses DifferentialEquations.jl.
Lorenz’s equations published in 1963 describe atmospheric convection and are very sensitive to the initial parameters. The work went unnoticed until 1972, when Lorenz gave a conference entitled “Predictability: does the flap of a butterfly’s wings in Brazil set off a tornado in Texas?”, which made famous the “butterfly effect” and led to the chaos theory.
The electronic computer used (Royal McBee LGP-30) was according to Lorenz only 1000 times faster than manual computing… Julia code allows writing this problem compactly with clear syntax, and to collect the solution on today’s laptops within 1 ms.

using DifferentialEquations, ParameterizedFunctions, Plots
lorenz = @ode_def begin                  # define the system
    dx = σ*(y - x);  dy = x*(ρ - z) - y; dz = x*y - β*z
 end σ ρ β
u0=[1.,1.,1.]; tspan=(0.,60.); p=[10.,28.,8/3];  # initial conds., timespan and parms.
prob = ODEProblem(lorenz, u0, tspan, p)  # define the problem
sol0 = solve(prob, reltol=1e-9)          # solve it
plot(sol0, vars = (1, 2, 3))             # display it

lorenz

35 Likes