In [2]:
using PyPlot
using Interact
In [3]:
T = 1.
function forward_euler_integrate(N::Int,T::Float64)
    y = zeros(N+1)
    h = T/N
    y[1] = 1.
    for i=1:N
        y[i+1]= y[i] + h*y[i]^2
    end
    return h, y
end
f=figure();
@manipulate for N=1:1000; withfig(f) do
        h, y = forward_euler_integrate(N, T)
        PyPlot.plot(0:h:T, y);
    end
end
Out[3]:
In [8]:
T = 50.
function forward_euler_integrate(N::Int,T::Float64)
    y = zeros(2,N+1)
    h = T/N
    A = [-0.01 1; -1 -0.01]
    y[:,1] = [0.;1.]
    for i=1:N
        y[:,i+1]= y[:,i] + h*A*y[:,i]
    end
    return h, y
end
#forward_euler_integrate(5,5.)
f=figure();
@manipulate for N=1:10000; withfig(f) do
        h, y = forward_euler_integrate(N, T)
        PyPlot.plot(collect(0:h:T), y');
    end
end
Out[8]:
In [7]:
T =500.
h, y = forward_euler_integrate(100000, T)
PyPlot.plot(collect(0:h:T), y');
In [7]:
Pkg.update()
INFO: Updating METADATA...
INFO: Updating cache of ColorTypes...
INFO: Updating cache of ReverseDiffSource...
INFO: Updating cache of FixedSizeArrays...
INFO: Updating cache of IJulia...
INFO: Updating cache of Clang...
INFO: Updating cache of ColorVectorSpace...
INFO: Updating cache of ProfileView...
INFO: Updating cache of UnicodePlots...
INFO: Updating cache of Interact...
INFO: Updating cache of Reactive...
INFO: Updating cache of Clang...
INFO: Updating JuliaParser...
INFO: Updating ProfileView...
INFO: Updating DGFun...
INFO: Computing changes...
WARNING: julia is fixed at 0.4.5 conflicting with requirement for JuliaParser: [0.5.0-,∞)
LoadError: AbstractTrees can't be installed because it has no versions that support 0.4.5 of julia. You may need to update METADATA by running `Pkg.update()`
while loading In[7], in expression starting on line 1

 in error at error.jl:22
 in resolve at /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib
 in update at /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib
 in anonymous at pkg/dir.jl:31
 in cd at /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib
 in cd at pkg/dir.jl:31
 in update at /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib