CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Avatar for Testing 18.04.

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download
Project: Testing 18.04
Views: 806
Kernel: Julia 1.0

Julia 1.0 Kernel in CoCalc

Here is the other common building block for programming: Evaluating a block of code more than once, e.g. by either counting the iterations or until a condition is met (or no longer met). This is one of the most confusing parts of programming. So don't be shy to take your time inspecting this. Try to evaluate this little program in your head by reading the lines over and over again...

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
@printf("%.2f", pi)
3.14
1+1+1+23
26
VERSION
v"1.0.5"
ENV["JULIA_DEPOT_PATH"]
"/home/user/.julia:/ext/julia/depot/"
Pkg.installed()
using Pkg for (k, v) in Pkg.installed() println(k, ":::", (if nothing == v "N/A" else v end)) end
using Printf
s = 0 for i = [1 2 5 100 -1 5] s = s + i @printf("i = %4d → s = %4d\n", i, s) end
[sin(3.14), sin(3.141), sin(3.142)]
println("Hello", 99) x = 10 println("Interpolation $(5 + x)") @printf("pi = %.7f\n", float(pi))
Printf.@printf("%f %F %f %F\n", 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)
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="--")
┌ Info: Precompiling PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee] └ @ Base loading.jl:1192
Image in a Jupyter notebook
1-element Array{PyCall.PyObject,1}: PyObject <matplotlib.lines.Line2D object at 0x7f857bae0c50>
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")
Image in a Jupyter notebook
PyObject Text(0.5, 1, '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)
Ar = A["a,b,",:]
Ac = A[:,"a,b,"]
Av = A > "b,"

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()
# /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))