In [1]:
using PyPlot
using Blink,Interact

Unable to load WebIO. Please make sure WebIO works for your Jupyter client. For troubleshooting, please see the WebIO/IJulia documentation.

In [2]:
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();
ui = @manipulate for N=2000:2800; withfig(f) do
        h, y = forward_euler_integrate(N, T)
        PyPlot.plot(collect(0:h:T), y')
    end
end
w = Window()
body!(w,ui)
Out[2]:
Page(1, WebSocket(server, CONNECTED), Dict{String,Any}("webio" => Blink.AtomShell.var"#24#25"{Blink.AtomShell.WebIOBlinkComm}(Blink.AtomShell.WebIOBlinkComm(Window(1, Electron(Process(`/Users/dgleich/.julia/packages/Blink/u1xcH/deps/Julia.app/Contents/MacOS/Julia /Users/dgleich/.julia/packages/Blink/u1xcH/src/AtomShell/main.js port 6105`, ProcessRunning), Sockets.TCPSocket(RawFD(0x0000003b) active, 0 bytes waiting), Dict{String,Any}("callback" => Blink.var"#1#2"())), Page(#= circular reference @-5 =#), Task (done) @0x000000011aad86d0))),"callback" => Blink.var"#1#2"()), Distributed.Future(1, 1, 1, Some(true)))
In [3]:
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();
ui = @manipulate for N=2000:2800; withfig(f) do
        h, y = forward_euler_integrate(N, T)
        PyPlot.plot(collect(0:h:T), sum(collect(y.^2),dims=1)')
    end
end
w = Window()
body!(w,ui)
Out[3]:
Page(2, WebSocket(server, CONNECTED), Dict{String,Any}("webio" => Blink.AtomShell.var"#24#25"{Blink.AtomShell.WebIOBlinkComm}(Blink.AtomShell.WebIOBlinkComm(Window(2, Electron(Process(`/Users/dgleich/.julia/packages/Blink/u1xcH/deps/Julia.app/Contents/MacOS/Julia /Users/dgleich/.julia/packages/Blink/u1xcH/src/AtomShell/main.js port 6105`, ProcessRunning), Sockets.TCPSocket(RawFD(0x0000003b) active, 0 bytes waiting), Dict{String,Any}("callback" => Blink.var"#1#2"())), Page(#= circular reference @-5 =#), Task (done) @0x000000011a620250))),"callback" => Blink.var"#1#2"()), Distributed.Future(1, 1, 2, Some(true)))
Unexpected end of input
 ...when parsing byte with value '0'
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] _error(::String, ::JSON.Parser.StreamingParserState{Sockets.TCPSocket}) at /Users/dgleich/.julia/packages/JSON/d89fA/src/Parser.jl:150
 [3] byteat(::JSON.Parser.StreamingParserState{Sockets.TCPSocket}) at /Users/dgleich/.julia/packages/JSON/d89fA/src/Parser.jl:59
 [4] current at /Users/dgleich/.julia/packages/JSON/d89fA/src/Parser.jl:72 [inlined]
 [5] chomp_space! at /Users/dgleich/.julia/packages/JSON/d89fA/src/Parser.jl:117 [inlined]
 [6] parse_value(::JSON.Parser.ParserContext{Dict{String,Any},Int64,true,nothing}, ::JSON.Parser.StreamingParserState{Sockets.TCPSocket}) at /Users/dgleich/.julia/packages/JSON/d89fA/src/Parser.jl:160
 [7] parse(::Sockets.TCPSocket; dicttype::Type{T} where T, inttype::Type{Int64}, allownan::Bool, null::Nothing) at /Users/dgleich/.julia/packages/JSON/d89fA/src/Parser.jl:494
 [8] parse at /Users/dgleich/.julia/packages/JSON/d89fA/src/Parser.jl:492 [inlined]
 [9] macro expansion at /Users/dgleich/.julia/packages/Lazy/9Xnd3/src/macros.jl:268 [inlined]
 [10] macro expansion at /Users/dgleich/.julia/packages/Blink/u1xcH/src/AtomShell/process.jl:111 [inlined]
 [11] (::Blink.AtomShell.var"#9#10"{Electron})() at ./task.jl:356
In [7]:
using LinearAlgebra
A = [-0.01 1; -1 -0.01]
@show abs.(eigvals(I(2)+(50 ./ 2501)*A))
abs.(eigvals(I(2) + (50 ./ 2501) * A)) = [0.9999999400479694, 0.9999999400479694]
Out[7]:
2-element Array{Float64,1}:
 0.9999999400479694
 0.9999999400479694
In [ ]: