Skip to content

Instantly share code, notes, and snippets.

@ChrisRackauckas
Created July 31, 2016 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisRackauckas/d05ffcfe3bd9bd99cc02e84bbeb56bbe to your computer and use it in GitHub Desktop.
Save ChrisRackauckas/d05ffcfe3bd9bd99cc02e84bbeb56bbe to your computer and use it in GitHub Desktop.
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.4.6 (2016-06-19 17:16 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-w64-mingw32
julia> Pkg.add("DifferentialEquations")
INFO: Initializing package repository C:\Users\Chris\.julia\v0.4
INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl
INFO: Cloning cache of BinDeps from git://github.com/JuliaLang/BinDeps.jl.git
INFO: Cloning cache of Blosc from git://github.com/stevengj/Blosc.jl.git
INFO: Cloning cache of Calculus from git://github.com/johnmyleswhite/Calculus.jl.git
INFO: Cloning cache of ChunkedArrays from git://github.com/ChrisRackauckas/ChunkedArrays.jl.git
INFO: Cloning cache of ColorTypes from git://github.com/JuliaGraphics/ColorTypes.jl.git
INFO: Cloning cache of Colors from git://github.com/JuliaGraphics/Colors.jl.git
INFO: Cloning cache of Compat from git://github.com/JuliaLang/Compat.jl.git
INFO: Cloning cache of DataStructures from git://github.com/JuliaLang/DataStructures.jl.git
INFO: Cloning cache of DifferentialEquations from git://github.com/ChrisRackauckas/DifferentialEquations.jl.git
INFO: Cloning cache of Distances from git://github.com/JuliaStats/Distances.jl.git
INFO: Cloning cache of DualNumbers from git://github.com/JuliaDiff/DualNumbers.jl.git
INFO: Cloning cache of EllipsisNotation from git://github.com/ChrisRackauckas/EllipsisNotation.jl.git
INFO: Cloning cache of FileIO from git://github.com/JuliaIO/FileIO.jl.git
INFO: Cloning cache of FixedPointNumbers from git://github.com/JeffBezanson/FixedPointNumbers.jl.git
INFO: Cloning cache of FixedSizeArrays from git://github.com/SimonDanisch/FixedSizeArrays.jl.git
INFO: Cloning cache of ForwardDiff from git://github.com/JuliaDiff/ForwardDiff.jl.git
INFO: Cloning cache of GrowableArrays from git://github.com/ChrisRackauckas/GrowableArrays.jl.git
INFO: Cloning cache of HDF5 from git://github.com/JuliaIO/HDF5.jl.git
INFO: Cloning cache of IterativeSolvers from git://github.com/JuliaLang/IterativeSolvers.jl.git
INFO: Cloning cache of Iterators from git://github.com/JuliaLang/Iterators.jl.git
INFO: Cloning cache of JLD from git://github.com/JuliaIO/JLD.jl.git
INFO: Cloning cache of LegacyStrings from https://github.com/JuliaArchive/LegacyStrings.jl.git
INFO: Cloning cache of LibExpat from git://github.com/amitmurthy/LibExpat.jl.git
INFO: Cloning cache of Measures from git://github.com/dcjones/Measures.jl.git
INFO: Cloning cache of NLsolve from git://github.com/EconForge/NLsolve.jl.git
INFO: Cloning cache of NaNMath from git://github.com/mlubin/NaNMath.jl.git
INFO: Cloning cache of Optim from git://github.com/JuliaOpt/Optim.jl.git
INFO: Cloning cache of Parameters from git://github.com/mauro3/Parameters.jl.git
INFO: Cloning cache of PlotUtils from git://github.com/JuliaPlots/PlotUtils.jl.git
INFO: Cloning cache of Plots from git://github.com/tbreloff/Plots.jl.git
INFO: Cloning cache of PositiveFactorizations from git://github.com/timholy/PositiveFactorizations.jl.git
INFO: Cloning cache of RecipesBase from git://github.com/JuliaPlots/RecipesBase.jl.git
INFO: Cloning cache of Reexport from git://github.com/simonster/Reexport.jl.git
INFO: Cloning cache of SHA from git://github.com/staticfloat/SHA.jl.git
INFO: Cloning cache of Showoff from git://github.com/JuliaGraphics/Showoff.jl.git
INFO: Cloning cache of URIParser from git://github.com/JuliaWeb/URIParser.jl.git
INFO: Cloning cache of WinRPM from git://github.com/JuliaLang/WinRPM.jl.git
INFO: Cloning cache of Zlib from git://github.com/dcjones/Zlib.jl.git
INFO: Installing BinDeps v0.4.1
INFO: Installing Blosc v0.1.6
INFO: Installing Calculus v0.1.15
INFO: Installing ChunkedArrays v0.0.2
INFO: Installing ColorTypes v0.2.5
INFO: Installing Colors v0.6.6
INFO: Installing Compat v0.8.6
INFO: Installing DataStructures v0.4.5
INFO: Installing DifferentialEquations v0.0.3
INFO: Installing Distances v0.3.2
INFO: Installing DualNumbers v0.2.2
INFO: Installing EllipsisNotation v0.0.2
INFO: Installing FileIO v0.1.0
INFO: Installing FixedPointNumbers v0.1.4
INFO: Installing FixedSizeArrays v0.2.2
INFO: Installing ForwardDiff v0.2.2
INFO: Installing GrowableArrays v0.0.4
INFO: Installing HDF5 v0.6.4
INFO: Installing IterativeSolvers v0.2.2
INFO: Installing Iterators v0.1.9
INFO: Installing JLD v0.6.3
INFO: Installing LegacyStrings v0.1.1
INFO: Installing LibExpat v0.1.4
INFO: Installing Measures v0.0.3
INFO: Installing NLsolve v0.7.3
INFO: Installing NaNMath v0.2.1
INFO: Installing Optim v0.5.0
INFO: Installing Parameters v0.3.1
INFO: Installing PlotUtils v0.0.4
INFO: Installing Plots v0.8.1
INFO: Installing PositiveFactorizations v0.0.2
INFO: Installing RecipesBase v0.0.6
INFO: Installing Reexport v0.0.3
INFO: Installing SHA v0.2.0
INFO: Installing Showoff v0.0.7
INFO: Installing URIParser v0.1.5
INFO: Installing WinRPM v0.2.0
INFO: Installing Zlib v0.1.12
INFO: Building Blosc
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\BinDeps.ji for module BinDeps.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\Compat.ji for module Compat.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\URIParser.ji for module URIParser.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\SHA.ji for module SHA.
INFO: Building Plots
INFO: Cannot find deps/plotly-latest.min.js... downloading latest version.
INFO: Building WinRPM
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\Zlib.ji for module Zlib.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\LegacyStrings.ji for module LegacyStrings.
WARNING: skipping repodata/repomd.xml, not in cache -- call WinRPM.update() to download
WARNING: skipping repodata/repomd.xml, not in cache -- call WinRPM.update() to download
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/repomd.xml
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/44abb30b4ceaa0feb5fb419b27bdc69aebd083898c2745c814a6d807eccac8ed-primary.xml.gz
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_13.2/repodata/repomd.xml
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_13.2/repodata/157a6fe5f0ef965d995ae95338fdced7345687bde7cc0b2e229d7aee72149983-primary.xml.gz
INFO: Building HDF5
INFO: Updating WinRPM package list
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/repomd.xml
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_13.2/repodata/repomd.xml
INFO: Package database updated
julia> Pkg.checkout("DifferentialEquations")
INFO: Checking out DifferentialEquations master...
INFO: Pulling DifferentialEquations latest master...
INFO: Removing BinDeps v0.4.1
INFO: Removing Blosc v0.1.6
INFO: Removing Calculus v0.1.15
INFO: Removing Distances v0.3.2
INFO: Removing DualNumbers v0.2.2
INFO: Removing FileIO v0.1.0
INFO: Removing ForwardDiff v0.2.2
INFO: Removing HDF5 v0.6.4
INFO: Removing JLD v0.6.3
INFO: Removing LegacyStrings v0.1.1
INFO: Removing LibExpat v0.1.4
INFO: Removing NLsolve v0.7.3
INFO: Removing NaNMath v0.2.1
INFO: Removing Optim v0.5.0
INFO: Removing PositiveFactorizations v0.0.2
INFO: Removing SHA v0.2.0
INFO: Removing URIParser v0.1.5
INFO: Removing WinRPM v0.2.0
INFO: Removing Zlib v0.1.12
julia> using DifferentialEquations, Plots
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\DifferentialEquations.ji for module DifferentialEquations.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\IterativeSolvers.ji for module IterativeSolvers.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\Parameters.ji for module Parameters.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\DataStructures.ji for module DataStructures.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\Plots.ji for module Plots.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\Reexport.ji for module Reexport.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\FixedSizeArrays.ji for module FixedSizeArrays.
WARNING: could not import LinAlg._chol! into FixedSizeArrays
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\RecipesBase.ji for module RecipesBase.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\PlotUtils.ji for module PlotUtils.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\Colors.ji for module Colors.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\FixedPointNumbers.ji for module FixedPointNumbers.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\ColorTypes.ji for module ColorTypes.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\Showoff.ji for module Showoff.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\Iterators.ji for module Iterators.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\Measures.ji for module Measures.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\EllipsisNotation.ji for module EllipsisNotation.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\GrowableArrays.ji for module GrowableArrays.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\ChunkedArrays.ji for module ChunkedArrays.
julia>
julia> """Example problem with solution ``u(t)=u0*exp(α*t)``"""
"Example problem with solution ``u(t)=u0*exp(α*t)``"
julia> function vanDerPolExample(u0=[0;sqrt(3)])
f1(u,t) = (1-u[2].^2)*u[1] - u[2]
f2(u,t) = u[1]
f(u,t) = [f1(u,t);f2(u,t)]
return(ODEProblem(f,u0))
end
vanDerPolExample (generic function with 2 methods)
julia> prob = vanDerPolExample()
DifferentialEquations.ODEProblem(f,[0.0,1.7320508075688772],(anonymous function),false,2,(2,))
julia> δt = 1//2^(4) #The initial timestepping size. It will automatically assigjulia> δt = 1//2^(4) #The initial timestepping size. It will automatically assigned if not given.
1//16
julia> tspan = [0,20] # The timespan. This is the default if not given.
2-element Array{Int64,1}:
0
20
julia> sol =solve(prob::ODEProblem,tspan,δt=δt,alg=:ode45)
[DifferentialEquations.jl] Initializing backend: ODEJL
WARNING: Couldn't initialize ODEJL. (might need to install it?)
ERROR: ArgumentError: ODE not found in path
in require at loading.jl:249
in init_package at C:\Users\Chris\.julia\v0.4\DifferentialEquations\src\general/backends.jl:23
in initialize_backend at C:\Users\Chris\.julia\v0.4\DifferentialEquations\src\general/backends.jl:5
in solve at C:\Users\Chris\.julia\v0.4\DifferentialEquations\src\ode/ode_solve.jl:216
julia> Pkg.clone("https://github.com/JuliaODE/ODE.jl")
INFO: Cloning ODE from https://github.com/JuliaODE/ODE.jl
INFO: Computing changes...
INFO: Cloning cache of Polynomials from git://github.com/Keno/Polynomials.jl.git
INFO: Installing Calculus v0.1.15
INFO: Installing ForwardDiff v0.2.2
INFO: Installing NaNMath v0.2.1
INFO: Installing Polynomials v0.0.5
INFO: Package database updated
julia> Pkg.checkout("ODE","dev")
INFO: Checking out ODE dev...
INFO: Pulling ODE latest dev...
INFO: No packages to install, update or remove
julia> sol =solve(prob::ODEProblem,tspan,δt=δt,alg=:ode45)
[DifferentialEquations.jl] Initializing backend: ODEJL
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\Polynomials.ji for module Polynomials.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\ForwardDiff.ji for module ForwardDiff.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\Calculus.ji for module Calculus.
INFO: Recompiling stale cache file C:\Users\Chris\.julia\lib\v0.4\NaNMath.ji for module NaNMath.
DifferentialEquations.ODESolution, 225 timesteps, final value [-0.4319028971751859,1.9224255971025037]
julia> sol[end]
1x2 Array{Float64,2}:
-0.431903 1.92243
julia> sol =solve(prob::ODEProblem,tspan,δt=δt,alg=:RK4)
DifferentialEquations.ODESolution, 321 timesteps, final value [-0.4318704079312779,1.9224422697071308]
julia> sol[end]
1x2 Array{Float64,2}:
-0.43187 1.92244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment