Sharedjulia-1.ipynbOpen in CoCalc

# Julia 1.0 Kernel in CoCalc¶

1+1+1

3
VERSION

v"1.0.3"
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.1 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

Welcome to Nemo version 0.12.1 Nemo comes with absolutely no warranty whatsoever

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)

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 0x7f7b8b042a20>
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)

(0, sin(0.2*pi), 0)

## Unicode Plots¶

using Plots
unicodeplots()

# /Users/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 50:

+------------------------------------------------------------+ 1.0599669777078058 | _r--__ .__r--r-.__. ._---_ | | / "-.. ._-/" | ""\-_. ..-" "\ | | | '. .r/ | '.. .- | | | | .^l. | ./{. | | | | ./ ". | ./ ". | | | . ./ "\. | ./ ". . | | \. r \. | ./ '. | | | \ / \. | ./ \. / | | ", ./ \. | ./ \. . | | \v \.L/ \. | |""""=/T"""""""""""""""""""""=/@="""""""""""""""""""""]"|""""| | ./ ". ./ | \.. . \. | | / ". ./ | \. .r \ | | / \. .." | \. ./ . | | | ".. .r | \.. .r \ | | | '.. .- | '.. ., | | | | '_/ | '\r | | | | .r" "\.. | ../ \.. . | | \. _-/ ""-._. | ._.-" "\-_. / | -1.0599669777078058 | '---"" """--r-/"" ""--/" | +------------------------------------------------------------+ -1.0599669777078058 1.0599669777078058