Help talk:Julia

From CECS wiki
Jump to navigation Jump to search

Presentation or workshop ideas[edit]

This is a brainstorm of a potential outline for a julia presentation (15m) or workshop (1h) on julia.

  • Overview
    • replaces MatLab, R, python
      • matlab to julia translator
      • includes libraries from python, R
    • interpreted and compiled (LLVM)
    • direct integration of external code (C shared libs, R, python) is possible
    • hierarchical types (number, etc.)
      • number: Abstract(Integer, Real, Rational, Complex, Irrational) Int64 Float64 BigInt BigFloat Rational
    • symbolics (\pi π etc.) Base.MathConstants
  • REPL user interface
    • \pi tab
    • built in help via ? followed by search word
      • ?int
      • ?big
    • [ add package...
  • Examples to cover
    • typeof()
    • subtypes(Number) // real type tree
    • julia types and rational Pi (2-3m)
      • 1/3 vs 1//3
      • rationalize(Int8, pi) // also Int64 BigInt
      • rationalize(Int, pi, tol=0.2) [1]
      • rationalize(BigInt,setprecision(BigFloat,1024) do; BigFloat(pi) end, tol=BigFloat("1e-1024"))
      • eps(1.5)
      • eps(1500.0)
      • eps(BigFloat(1500))
      • using IrrationalConstants; names(IrrationalConstants)
    • matrixes
      • literal
      • matrix fuctions
    • using (and finding?) packages
    • ODE example (see below)
    • simple plot demo (with matricies, below)
    • surface plot demo [2]

future topics to research[edit]

  • Examples
    • complex numbers
    • benchmark? vs. other languages
    • parallel or distributed computing example
    • gpu / linear algebra example
    • machine learning example
    • example translating matlab to julia (10-15m)
    • example with jupyter notebook
    • example with pluto
    • (advanced) example calling external C / python / R
    • julia + slurm
    • pandas or polars(julia/rust) example

Short presentation might include one or two examples from this list.

Types tree[edit]

using AbstractTrees
AbstractTrees.children(d::DataType) = subtypes(d)
print_tree(Number)

Simple plots example[edit]

Sine.png
using Plots
x=range(-10,10,length=100)
y=sin.(x)
plot(x,y)

Surface plot example[edit]

Sine3d.png
using Plots
x = y = -10:0.1:10
d(x,y) = sqrt(x*x+y*y)
f(x,y) = sin(d(x,y))/(d(x,y)+1)
z = f.(x', y)
surface(x, y, z)

Points of interest:

  • range definition
  • short form function definition
  • matrix application of linear function
    • permute variable in matrix function call (x')

ODE example[edit]

Lorenz.png

Install

using Pkg
Pkg.add("OrdinaryDiffEq")
using Plots
using OrdinaryDiffEq
function lorenz!(du,u,p,t)
 du[1] = 10.0(u[2]-u[1])
 du[2] = u[1]*(28.0-u[3]) - u[2]
 du[3] = u[1]*u[2] - (8/3)*u[3]
end
u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
prob = ODEProblem(lorenz!,u0,tspan)
sol = solve(prob,Tsit5())
plot(sol,idxs=(1,2,3))

References: OrdinaryDiffEq DifferentialEquations Plots tutorial

tweaks[edit]

env vars

  • JULIA_DEPOT_PATH (defaults to ~/.julia ??)
  • JULIA_NUM_THREADS defaults to 1 (alt: auto)

External links[edit]