Open in CoCalc

Julia 1.0 Kernel in CoCalc

In [1]:
1+1+1+23
26
In [2]:
VERSION
v"1.0.4"
In [3]:
ENV["JULIA_DEPOT_PATH"]
"/home/user/.julia:/ext/julia/depot/"
In [4]:
Pkg.installed()
UndefVarError: Pkg not defined Stacktrace: [1] top-level scope at In[4]:1
In [ ]:
using Pkg for (k, v) in Pkg.installed() println(k, ":::", (if nothing == v "N/A" else v end)) end
In [5]:
using Printf
In [6]:
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
In [7]:
[sin(3.14), sin(3.141), sin(3.142)]
3-element Array{Float64,1}: 0.0015926529164868282 0.0005926535550994539 -0.00040734639894142617
In [8]:
println("Hello", 99) x = 10 println("Interpolation $(5 + x)") @printf("pi = %.7f\n", float(pi))
Hello99 Interpolation 15 pi = 3.1415927
In [9]:
Printf.@printf("%f %F %f %F\n", Inf, Inf, NaN, NaN)
Inf Inf NaN NaN
In [10]:
using CSV
In [11]:
using DataFrames
In [12]:
#using Gadfly
In [13]:
using Nemo
ArgumentError: Package Nemo not found in current path: - Run `import Pkg; Pkg.add("Nemo")` to install the Nemo package. Stacktrace: [1] require(::Module, ::Symbol) at ./loading.jl:823 [2] top-level scope at In[13]:1

In [14]:
using Statistics
In [15]:
Statistics.median([8 9 8 6 87 6 7 6 5.1 4 5 4 3 4 3 3 3 3 ])
5.05
In [16]:
using LinearAlgebra
In [17]:
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
In [18]:
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

In [ ]:
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)
In [ ]:
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)
In [ ]:
using GLM

In [4]:
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="--")
┌ Info: Precompiling PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee] └ @ Base loading.jl:1192
1-element Array{PyCall.PyObject,1}: PyObject <matplotlib.lines.Line2D object at 0x7f2addd010f0>
In [5]:
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")
PyObject Text(0.5,1,'A sinusoidally modulated sinusoid')

In [21]:
using D4M
┌ Info: Recompiling stale cache file /home/user/.julia/compiled/v1.1/D4M/JhFK0.ji for D4M [ca196bdc-a701-11e8-3d50-3b5cc8577617] └ @ Base loading.jl:1184
Not loading database capabilities. If you would like to connect to a database, please set JAVA_HOME.
In [22]:
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)
In [23]:
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)
In [24]:
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)
In [25]:
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

In [1]:
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

In [2]:
using Plots unicodeplots()
Plots.UnicodePlotsBackend()
In [3]:
# /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
In [ ]: