Sharedjulia-1.1.ipynbOpen in CoCalc

Julia 1.1 Kernel in CoCalc

1+1+1
3
VERSION
v"1.1.0"
ENV["JULIA_DEPOT_PATH"]
"/home/user/.julia:/ext/julia/julia/depot/"
using Pkg
for (k, v) in Pkg.installed()
    println(k, ":::", (if nothing == v "N/A" else v end))
end
CSV:::0.4.3 D4M:::0.1.0 Interact:::0.9.0 Statistics:::N/A Optim:::0.17.2 JuMP:::0.18.5 LinearAlgebra:::N/A Plotly:::0.2.0 Ipopt:::0.5.3 Combinatorics:::0.7.0 SymPy:::0.8.3 Compat:::1.5.1 IJulia:::1.16.0 Plots:::0.23.0 PyPlot:::2.7.0 Calculus:::0.4.1 Gadfly:::1.0.1 Nemo:::0.12.2 DifferentialEquations:::6.2.0 DataFrames:::0.17.1 UnicodePlots:::1.1.0 GLM:::1.1.0
using Printf
s = 0
for i = [1 2 5 100 -1 5]
    s = s + i
    @printf("i = %4d  →  s = %4d\n", i, s)
end
i = 1 → s = 1 i = 2 → s = 3 i = 5 → s = 8 i = 100 → s = 108 i = -1 → s = 107 i = 5 → s = 112
[sin(3.14), sin(3.141), sin(3.142)]
3-element Array{Float64,1}: 0.0015926529164868282 0.0005926535550994539 -0.00040734639894142617
println("Hello", 99)
x = 10
println("Interpolation $(5 + x)")
@printf("pi = %.7f\n", float(pi))
Hello99 Interpolation 15 pi = 3.1415927
Printf.@printf("%f %F %f %F\n", Inf, Inf, NaN, NaN)
Inf Inf NaN NaN
using CSV
using DataFrames
#using Gadfly
using Nemo

using Statistics
Statistics.median([8 9 8 6 87 6 7 6 5.1 4 5 4 3 4 3 3 3 3 ])
5.05
using LinearAlgebra
m1 = [  1 2 -3
        3 -1 1
        1.0 1 1]

q1, r1 = LinearAlgebra.qr(m1)
LinearAlgebra.QRCompactWY{Float64,Array{Float64,2}} Q factor: 3×3 LinearAlgebra.QRCompactWYQ{Float64,Array{Float64,2}}: -0.301511 0.816497 -0.492366 -0.904534 -0.408248 -0.123091 -0.301511 0.408248 0.86164 R factor: 3×3 Array{Float64,2}: -3.31662 2.22045e-16 -0.301511 0.0 2.44949 -2.44949 0.0 0.0 2.21565
q1 * r1
3×3 Array{Float64,2}: 1.0 2.0 -3.0 3.0 -1.0 1.0 1.0 1.0 1.0

using DifferentialEquations
α=1
β=1
u₀=1/2
f(t,u) = α*u
g(t,u) = β*u
dt = 1//2^(4)
tspan = (0.0,1.0)
prob = SDEProblem(f,g,u₀,(0.0,1.0))
sol = solve(prob,EM(),dt=dt)
using Plots
plot(sol)
MethodError: no method matching f(::Float64, ::Nothing, ::Float64) Closest candidates are: f(::Any, ::Any) at In[1]:5 Stacktrace: [1] (::SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing})(::Float64, ::Nothing, ::Vararg{Any,N} where N) at /ext/julia/depot/packages/DiffEqBase/PvfXM/src/diffeqfunction.jl:144 [2] perform_step!(::StochasticDiffEq.SDEIntegrator{EM{true},false,Float64,Float64,Float64,Nothing,Float64,Float64,Float64,NoiseProcess{Float64,1,Float64,Float64,Nothing,Nothing,typeof(DiffEqNoiseProcess.WHITE_NOISE_DIST),typeof(DiffEqNoiseProcess.WHITE_NOISE_BRIDGE),false,DataStructures.Stack{Tuple{Float64,Float64,Nothing}},ResettableStacks.ResettableStack{Tuple{Float64,Float64,Nothing},false},RSWM{:RSwM1,Float64},RandomNumbers.Xorshifts.Xoroshiro128Plus},Float64,RODESolution{Float64,1,Array{Float64,1},Nothing,Nothing,Array{Float64,1},NoiseProcess{Float64,1,Float64,Float64,Nothing,Nothing,typeof(DiffEqNoiseProcess.WHITE_NOISE_DIST),typeof(DiffEqNoiseProcess.WHITE_NOISE_BRIDGE),false,DataStructures.Stack{Tuple{Float64,Float64,Nothing}},ResettableStacks.ResettableStack{Tuple{Float64,Float64,Nothing},false},RSWM{:RSwM1,Float64},RandomNumbers.Xorshifts.Xoroshiro128Plus},SDEProblem{Float64,Tuple{Float64,Float64},false,Nothing,Nothing,SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),Nothing,Nothing},EM{true},StochasticDiffEq.LinearInterpolationData{Array{Float64,1},Array{Float64,1}}},StochasticDiffEq.EMConstantCache,SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),StochasticDiffEq.SDEOptions{Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),CallbackSet{Tuple{},Tuple{}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,DataStructures.LessThan},Nothing,Nothing,Int64,Float64,Float64,Float64,Array{Float64,1},Array{Float64,1},Array{Float64,1}},Nothing,Float64}, ::StochasticDiffEq.EMConstantCache, ::Function) at /ext/julia/depot/packages/StochasticDiffEq/My2gg/src/perform_step/low_order.jl:4 [3] perform_step!(::StochasticDiffEq.SDEIntegrator{EM{true},false,Float64,Float64,Float64,Nothing,Float64,Float64,Float64,NoiseProcess{Float64,1,Float64,Float64,Nothing,Nothing,typeof(DiffEqNoiseProcess.WHITE_NOISE_DIST),typeof(DiffEqNoiseProcess.WHITE_NOISE_BRIDGE),false,DataStructures.Stack{Tuple{Float64,Float64,Nothing}},ResettableStacks.ResettableStack{Tuple{Float64,Float64,Nothing},false},RSWM{:RSwM1,Float64},RandomNumbers.Xorshifts.Xoroshiro128Plus},Float64,RODESolution{Float64,1,Array{Float64,1},Nothing,Nothing,Array{Float64,1},NoiseProcess{Float64,1,Float64,Float64,Nothing,Nothing,typeof(DiffEqNoiseProcess.WHITE_NOISE_DIST),typeof(DiffEqNoiseProcess.WHITE_NOISE_BRIDGE),false,DataStructures.Stack{Tuple{Float64,Float64,Nothing}},ResettableStacks.ResettableStack{Tuple{Float64,Float64,Nothing},false},RSWM{:RSwM1,Float64},RandomNumbers.Xorshifts.Xoroshiro128Plus},SDEProblem{Float64,Tuple{Float64,Float64},false,Nothing,Nothing,SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),Nothing,Nothing},EM{true},StochasticDiffEq.LinearInterpolationData{Array{Float64,1},Array{Float64,1}}},StochasticDiffEq.EMConstantCache,SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),StochasticDiffEq.SDEOptions{Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),CallbackSet{Tuple{},Tuple{}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,DataStructures.LessThan},Nothing,Nothing,Int64,Float64,Float64,Float64,Array{Float64,1},Array{Float64,1},Array{Float64,1}},Nothing,Float64}, ::StochasticDiffEq.EMConstantCache) at /ext/julia/depot/packages/StochasticDiffEq/My2gg/src/perform_step/low_order.jl:2 [4] solve!(::StochasticDiffEq.SDEIntegrator{EM{true},false,Float64,Float64,Float64,Nothing,Float64,Float64,Float64,NoiseProcess{Float64,1,Float64,Float64,Nothing,Nothing,typeof(DiffEqNoiseProcess.WHITE_NOISE_DIST),typeof(DiffEqNoiseProcess.WHITE_NOISE_BRIDGE),false,DataStructures.Stack{Tuple{Float64,Float64,Nothing}},ResettableStacks.ResettableStack{Tuple{Float64,Float64,Nothing},false},RSWM{:RSwM1,Float64},RandomNumbers.Xorshifts.Xoroshiro128Plus},Float64,RODESolution{Float64,1,Array{Float64,1},Nothing,Nothing,Array{Float64,1},NoiseProcess{Float64,1,Float64,Float64,Nothing,Nothing,typeof(DiffEqNoiseProcess.WHITE_NOISE_DIST),typeof(DiffEqNoiseProcess.WHITE_NOISE_BRIDGE),false,DataStructures.Stack{Tuple{Float64,Float64,Nothing}},ResettableStacks.ResettableStack{Tuple{Float64,Float64,Nothing},false},RSWM{:RSwM1,Float64},RandomNumbers.Xorshifts.Xoroshiro128Plus},SDEProblem{Float64,Tuple{Float64,Float64},false,Nothing,Nothing,SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),Nothing,Nothing},EM{true},StochasticDiffEq.LinearInterpolationData{Array{Float64,1},Array{Float64,1}}},StochasticDiffEq.EMConstantCache,SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),StochasticDiffEq.SDEOptions{Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),CallbackSet{Tuple{},Tuple{}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,DataStructures.LessThan},Nothing,Nothing,Int64,Float64,Float64,Float64,Array{Float64,1},Array{Float64,1},Array{Float64,1}},Nothing,Float64}) at /ext/julia/depot/packages/StochasticDiffEq/My2gg/src/solve.jl:384 [5] #__solve#41(::Base.Iterators.Pairs{Symbol,Rational{Int64},Tuple{Symbol},NamedTuple{(:dt,),Tuple{Rational{Int64}}}}, ::Function, ::SDEProblem{Float64,Tuple{Float64,Float64},false,Nothing,Nothing,SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),Nothing,Nothing}, ::EM{true}, ::Array{Any,1}, ::Array{Any,1}, ::Type{Val{true}}) at /ext/julia/depot/packages/StochasticDiffEq/My2gg/src/solve.jl:7 [6] #__solve at ./none:0 [inlined] (repeats 4 times) [7] #solve#425(::Base.Iterators.Pairs{Symbol,Rational{Int64},Tuple{Symbol},NamedTuple{(:dt,),Tuple{Rational{Int64}}}}, ::Function, ::SDEProblem{Float64,Tuple{Float64,Float64},false,Nothing,Nothing,SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),Nothing,Nothing}, ::EM{true}) at /ext/julia/depot/packages/DiffEqBase/PvfXM/src/solve.jl:39 [8] (::getfield(DiffEqBase, Symbol("#kw##solve")))(::NamedTuple{(:dt,),Tuple{Rational{Int64}}}, ::typeof(solve), ::SDEProblem{Float64,Tuple{Float64,Float64},false,Nothing,Nothing,SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),Nothing,Nothing}, ::EM{true}) at ./none:0 [9] top-level scope at In[1]:10
using DifferentialEquations

f(x) = sin(2π.*x[:,1]).*cos(2π.*x[:,2])
gD(x) = sin(2π.*x[:,1]).*cos(2π.*x[:,2])/(8π*π)

dx = 1//2^(5)
mesh = notime_squaremesh([0 1 0 1],dx,:dirichlet)
prob = PoissonProblem(f,mesh,gD=gD)

sol = solve(prob)

using Plots
plot(sol)
using GLM

using PyPlot
x = range(0, stop = 4*pi, length=1000)
y = sin.(3*x + 1.5*cos.(2*x))
plot(x, y, color="red", linewidth=2.0, linestyle="--")
1-element Array{PyCall.PyObject,1}: PyObject <matplotlib.lines.Line2D object at 0x7f0a2610a9b0>
using PyPlot
x = range(0; stop=2*pi, length=1000); y = sin.(3 * x + 4 * cos.(2 * x));
plot(x, y, color="red", linewidth=2.0, linestyle="--")
title("A sinusoidally modulated sinusoid")

using D4M
row = "a,a,a,a,a,a,a,aa,aaa,b,bb,bbb,a,aa,aaa,b,bb,bbb,"
column = "a,aa,aaa,b,bb,bbb,a,a,a,a,a,a,a,aa,aaa,b,bb,bbb,"
values = "a-a,a-aa,a-aaa,a-b,a-bb,a-bbb,a-a,aa-a,aaa-a,b-a,bb-a,bbb-a,a-a,aa-aa,aaa-aaa,b-b,bb-bb,bbb-bbb,"

A = Assoc(row,column,values)
Assoc(Union{AbstractString, Number}["a", "aa", "aaa", "b", "bb", "bbb"], Union{AbstractString, Number}["a", "aa", "aaa", "b", "bb", "bbb"], Union{AbstractString, Number}["a-a", "a-aa", "a-aaa", "a-b", "a-bb", "a-bbb", "aa-a", "aa-aa", "aaa-a", "aaa-aaa", "b-a", "b-b", "bb-a", "bb-bb", "bbb-a", "bbb-bbb"], [1, 1] = 1 [2, 1] = 7 [3, 1] = 9 [4, 1] = 11 [5, 1] = 13 [6, 1] = 15 [1, 2] = 2 [2, 2] = 8 [1, 3] = 3 [3, 3] = 10 [1, 4] = 4 [4, 4] = 12 [1, 5] = 5 [5, 5] = 14 [1, 6] = 6 [6, 6] = 16)
Ar = A["a,b,",:]
Assoc(Union{AbstractString, Number}["a", "b"], Union{AbstractString, Number}["a", "aa", "aaa", "b", "bb", "bbb"], Union{AbstractString, Number}["a-a", "a-aa", "a-aaa", "a-b", "a-bb", "a-bbb", "b-a", "b-b"], [1, 1] = 1 [2, 1] = 7 [1, 2] = 2 [1, 3] = 3 [1, 4] = 4 [2, 4] = 8 [1, 5] = 5 [1, 6] = 6)
Ac = A[:,"a,b,"]
Assoc(Union{AbstractString, Number}["a", "aa", "aaa", "b", "bb", "bbb"], Union{AbstractString, Number}["a", "b"], Union{AbstractString, Number}["a-a", "a-b", "aa-a", "aaa-a", "b-a", "b-b", "bb-a", "bbb-a"], [1, 1] = 1 [2, 1] = 3 [3, 1] = 4 [4, 1] = 5 [5, 1] = 7 [6, 1] = 8 [1, 2] = 2 [4, 2] = 6)
Av = A > "b,"
Assoc(Union{AbstractString, Number}["b", "bb", "bbb"], Union{AbstractString, Number}["a", "b", "bb", "bbb"], Union{AbstractString, Number}["b-a", "b-b", "bb-a", "bb-bb", "bbb-a", "bbb-bbb"], [1, 1] = 1 [2, 1] = 3 [3, 1] = 5 [1, 2] = 2 [2, 3] = 4 [3, 4] = 6)

SymPy test

using SymPy
x = symbols("x")      # or   @vars x, Sym("x"), or  Sym(:x)
y = sin(pi*x)
y(1), y(2.2), y(123456)

Unicode Plots

using Plots
unicodeplots()
Plots.UnicodePlotsBackend()
# /Users/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 50:
plot(sin,x-> sin(1.5x), 0, 4π, line=1, leg=false, fill=(0,:orange))
+------------------------------------------------------------+ 1.0599669777078058 | _r--__ .__r--r-.__. ._---_ | | /` "-.. ._-/"` | ""\-_. ..-"` "\ | | |` '`. .r/` | '`.. .-` | | | | .^l. | ./{. | | | | ./` "`. | ./` "`. | | | . ./` "\. | ./` "`. . | | \. r` \. | ./` '. | | | \ / \. | ./ \. / | | ", ./ \. | ./ \. .` | | \v` \.L/ \.` | |""""=/T"""""""""""""""""""""=/@="""""""""""""""""""""]"|""""| | ./ ". ./ | \.. .` \. | | / ". ./ | \. .r` \ | | / \. .." | \. ./ . | | | ".. .r` | \.. .r` \ | | | '.. .-` | '.. .,` | | | | '_/` | '\r` | | | | .r" "\.. | ../` \.. .` | | \. _-/` ""-._. | ._.-"` "\-_. / | -1.0599669777078058 | '---"" """`--r-/""` ""--/" | +------------------------------------------------------------+ -1.0599669777078058 1.0599669777078058