# Seven Lines of Julia (examples sought)

**URL:** <https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416>\
**Category:** General Usage\
**Created:** [November 19, 2020, 7:37am UTC](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416 "2020-11-19T07:37:29Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 19, 2020, 10:09pm UTC](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416/4 "2020-11-19T22:09:54Z")

</div>

Julia code for the [Lorenz problem](https://en.wikipedia.org/wiki/Lorenz_system) provided in Wikipedia that uses [DifferentialEquations.jl](https://diffeq.sciml.ai/v3.0/).  
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.

```julia
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](https://global.discourse-cdn.com/julialang/original/3X/4/8/48730e42d3747dd884750892a3d1394ee6254685.png)

---

_[View the full topic](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416)._
