Julia & Ijulia Cheat-Sheet (For 18.Xxx at Mit, Julia 1.X) : Basics: Arithmetic and Functions of Numbers
Julia & Ijulia Cheat-Sheet (For 18.Xxx at Mit, Julia 1.X) : Basics: Arithmetic and Functions of Numbers
x)
Basics:
julialang.org — documentation; juliabox.com — run Julia online Arithmetic and functions of numbers:
github.com/mitmath/julia-mit installation & tutorial 3*4, 7+4, 2-6, 8/3 mult., add, sub., divide numbers
using IJulia; IJulia.notebook() start IJulia browser 3^7, 3^(8+2im) compute 3 or 3 power
7 8+2i
randn(12) Gaussian random numbers (mean 0, std. dev. 1) eigvals(A), eigvecs(A) eigenvalues and eigenvectors (columns)
I(3) or Matrix(I,3,3) 3×3 identity matrix I
range(1.2,4.7,length=100) 100 equally spaced points from 1.2 to 4.7 Plotting (type using PyPlot first)
Diagonal(x) matrix whose diagonal is the entries of x plot(y), plot(x,y) plot y vs. 0,1,2,3,… or versus x
loglog(x,y), semilogx(x,y), semilogy(x,y) log-scale plots
Portions of matrices and vectors: title("A title"), xlabel("x-axis"), ylabel("foo") set labels
x[2:12] the 2 to 12 elements of x
nd th
legend(["curve 1", "curve 2"], "northwest") legend at upper-left
x[2:end] the 2 to the last elements of x
nd
grid(), axis("equal") add grid lines, use equal x and y scaling
A[5,1:3] row vector of 1 3 elements in 5 row of A
st th
title(L"the curve $e^\sqrt{x}$") title with LaTeX equation
A[5,:] row vector of 5 row of A
th
savefig("fig.png"), savefig("fig.pdf") save PNG or PDF image
diag(A) vector of diagonals of A