In [1]:
using DifferentialEquations

In [2]:
μ = 0.456
ϵ = 0.0357

function bluesky(du,u,p,t)
du[1] = u[1]*(2+μ-10(u[1]^2+u[2]^2)) + u[3]^2 + u[2]^2+2u[2]
du[2] = -u[3]^3-(1+u[2])*(u[3]^2+u[2]^2+2u[2])-4*u[1]+μ*u[2]
du[3] = (1+u[2])*u[3]^2+u[1]^2-ϵ
end

Out[2]:
bluesky (generic function with 1 method)
In [3]:
u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
prob = ODEProblem(bluesky,u0,tspan)
sol = solve(prob)

Out[3]:
retcode: Success
Interpolation: specialized 4th order "free" interpolation
t: 533-element Array{Float64,1}:
0.0
0.000242794
0.00267074
0.0091564
0.0196942
0.034228
0.0547106
0.0828306
0.121833
0.175646
0.250851
0.361763
0.480232
⋮
97.327
97.5545
97.755
97.9734
98.1957
98.4781
98.7962
99.0634
99.3472
99.6414
99.9307
100.0
u: 533-element Array{Array{Float64,1},1}:
[1.0, 0.0, 0.0]
[0.998174, -0.000970108, 0.000233683]
[0.980537, -0.0105562, 0.00252316]
[0.938275, -0.0352128, 0.00825583]
[0.881238, -0.0727312, 0.0165861]
[0.818717, -0.120308, 0.0265473]
[0.750202, -0.181046, 0.0384]
[0.677017, -0.255469, 0.0517152]
[0.595216, -0.346082, 0.0661592]
[0.497891, -0.453002, 0.0804787]
[0.371867, -0.573941, 0.0923551]
[0.198736, -0.698181, 0.0979653]
[0.0462886, -0.7658, 0.095936]
⋮
[-0.340419, 0.171288, -0.0124758]
[-0.264768, 0.314069, 0.00164854]
[-0.155254, 0.314244, 0.00354042]
[-0.045482, 0.246791, -0.00189027]
[0.0546987, 0.145436, -0.00962507]
[0.166218, -0.0172594, -0.0157618]
[0.212106, -0.229048, -0.0142034]
[0.133021, -0.364671, -0.0147955]
[-0.0280167, -0.369638, -0.0233519]
[-0.225648, -0.160061, -0.0281007]
[-0.340265, 0.175505, -0.0116722]
[-0.329319, 0.236798, -0.00631381]   
In [4]:
using Plots
plot(sol,vars=(1,2,3))

Out[4]:
In [16]:
plt = path3d(1, xlim=(-3,3), ylim=(-3,3), zlim=(-3,3),
xlab = "x", ylab = "y", zlab = "z",
title = "Gavrilov-A. Shilnikov model", marker = 1)

# build an animated gif, saving every 10th frame
@gif for i=1:length(sol)
push!(plt, sol[i][1], sol[i][2], sol[i][3])
end every 3

INFO: Saved animation to /Users/noriakioshita/Github/julia/ml_page/julia/tmp.gif

Out[16]:
In [22]:
function displayfile(mimetype, filename)
open(filename) do f
base64text = base64encode(f)
display("text/html", """<img src="data:$mimetype;base64,$base64text">""")
end
end

Out[22]:
displayfile (generic function with 1 method)
In [23]:
displayfile("image/gif","./bluesky.gif")

In [24]:
# ちょっと遅くしたもの
displayfile("image/gif","./bluesky2.gif")


jupyter notebook で実行するとぐりぐり出来る

In [20]:
plotly()
plot(sol[1,:],sol[2,:],sol[3,:], size=(500, 500))

Out[20]: