Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

📚 The CoCalc Library - books, templates and other resources

Views: 96190
License: OTHER
Kernel: Julia

Julia – a modern approach to scientific computing

https://www.julialang.org

Evaluate the following cell by selecting it and then hit Shift+Return. Watch the top right status indicator of the Jupyter Notebook kernel to have started up Julia. The result will appear below.

1 + 1
2

Vectors and matrices have a simple syntax. Notice, that the ' means to transpose this vector.

b = [1 4.4 -9]'
3×1 Array{Float64,2}: 1.0 4.4 -9.0
A = [ 1 9 1 0 1 0 -1.1 0 -1]
3×3 Array{Float64,2}: 1.0 9.0 1.0 0.0 1.0 0.0 -1.1 0.0 -1.0

… and here we solve this as a linear system of equations: A⋅x=bA \cdot x = b

x = A \ b
3×1 Array{Float64,2}: 476.0 4.4 -514.6
A * x
3×1 Array{Float64,2}: 1.0 4.4 -9.0

Batman Curve

Transcribed from Julia: A Fast Language for Numerical Computing, by Alan Edelman, SIAM News, Volume 49 | Number 02 | March 2016

# Note: the first time in a project, it can take over a minute to precompile PyPlot using PyPlot function batman() # bat functions: semicircle, ellipse, shoulders, bottom, cowl # harmless Compat.UTF8String warnings from julia kernel on first run σ(x) = sqrt.(1-x.^2) e(x) = 3σ(x/7) s(x) = 4.2 - .5x - 2.8σ(.5x-.5) b(x) = σ(abs.(2-x)-1)-x.^2/11 + .5x - 3 c(x) = [1.7, 1.7, 2.6, .9] # plot symmetrically across y-axis p(x,f) = plot(-x,f(x), color="black") , plot(x,f(x), color="black") p((3:.1:7),e);p(4:.1:7,t->-e(t)) # ellipse p(1:.1:3,s);p(0:.1:4,b) # shoulders and bottom p([0,.5,.8,1],c) end batman();