Created
August 1, 2016 00:11
-
-
Save ChrisRackauckas/9e75bbedec3df725851da6b54e9d6be9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_ | |
_ _ _(_)_ | 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> using ODE | |
julia> using DifferentialEquations | |
julia> Pkg.update() | |
INFO: Updating METADATA... | |
INFO: Cloning cache of ODE from git://github.com/JuliaLang/ODE.jl.git | |
INFO: Updating ODE... | |
INFO: Updating DifferentialEquations... | |
INFO: Computing changes... | |
INFO: No packages to install, update or remove | |
julia> Pkg.rm("ODE") | |
INFO: No packages to install, update or remove | |
INFO: Package database updated | |
julia> | |
julia> using DifferentialEquations, Plots | |
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> | |
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> | |
julia> sol =solve(prob::ODEProblem,tspan,δt=δt,alg=:ode45) | |
[DifferentialEquations.jl] Initializing backend: ODEJL | |
DifferentialEquations.ODESolution, 225 timesteps, final value [-0.4319028971751859,1.9224255971025037] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment