but look for hints of greater depth
A = randn(4,4)
x = rand(4)
b = A*x
x̂ = A\b
@show norm(A*x̂ - b)
norm(A * x̂ - b) = 2.3551386880256624e-16
2.3551386880256624e-16
U,Σ,V = svd(A);
U
4×4 Array{Float64,2}: 0.344883 0.242207 0.838568 0.345248 -0.634428 0.10505 0.477184 -0.598967 -0.0641412 0.962321 -0.262824 0.0273296 -0.688799 -0.065096 0.00482939 0.722008
U[:,1]
# show how to type and show Σ
err = norm(U*diagm(Σ)*V'-A)
9.468584479444362e-16
typeof(err)
Float64
A = randn(4,4) |> t -> t + t' # pipe A through map A -> A + A' to symmetrize it
λ = eigmax(A);
@show det(A - λ*I) # metaprogramming: print expression then evaluate it
;
det(A - λ * I) = 1.3111137536079468e-13
typeof(I)
UniformScaling{Int64}
using ODE
using PyPlot
(.:15138): Gtk-WARNING **: Theme parsing error: gtk.css:68:35: The style property GtkButton:child-displacement-x is deprecated and shouldn't be used anymore. It will be removed in a future version (.:15138): Gtk-WARNING **: Theme parsing error: gtk.css:69:35: The style property GtkButton:child-displacement-y is deprecated and shouldn't be used anymore. It will be removed in a future version (.:15138): Gtk-WARNING **: Theme parsing error: gtk.css:73:46: The style property GtkScrolledWindow:scrollbars-within-bevel is deprecated and shouldn't be used anymore. It will be removed in a future version ** (.:15138): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-WMSc4PD06G: Connection refused
# define Lorenz equations
function f(t, x)
σ = 10
β = 8/3
ρ = 28
[σ*(x[2]-x[1]); x[1]*(ρ-x[3]); x[1]*x[2] - β*x[3]]
end
# run f once
f(0, [0; 0; 0])
# integrate
t = 0:0.01:20.0
x₀ = [0.1; 0.0; 0.0]
t,x = ode45(f, x₀, t)
x = hcat(x...)' # rearrange storage of x (don't ask...)
# plot
plot3D(x[:,1], x[:,2], x[:,3], "b-")
xlabel("x")
ylabel("y")
zlabel("z")
xlim(-25,25)
ylim(-25,25)
zlim(0,60)
;
f(n) = n < 2 ? 1 : f(n-1) + f(n-2) # recursive function definition
for i = 0:10
println("f($i) = $(f(i))") # string interpolation
end