using LinearAlgebra A = [1 1 -2 4] eigvals(A) X = [1 1 1 2] x = [1,0] c = X \ x A*x Λ = Diagonal([2, 3]) X*Λ*c X * Λ * inv(X) * x X * Λ / X # / X is equivalent to multiplying by inv(X), but is more efficient A*X X*Λ X \ A * X S = randn(2,2) det(S) # a random S is almost certainly nonsingular B = S \ A * S # same as inv(S) * A * S, but more efficient since it avoids the explicit inverse eigvals(B) eigvals(A * S) det(A), det(B) det(A) 2 * 3 prod(eigvals(A)) Abig = randn(100,100) det(Abig) prod(eigvals(Abig)) logabsdet(Abig) # the log of the absolute value of the determinant, and the sign s = sum(log.(abs.(eigvals(Abig)))) # the sum of the logs of |λ| Abigger = randn(1000,1000) det(Abigger) floatmax(Float64) # the problem is that there is a maximum value the computer can represent, beyond which it gives "Inf" logabsdet(Abigger) # but the log is fine s = sum(log.(abs.(eigvals(Abigger)))) # the sum of the logs of |λ| tr(A) 2 + 3 sum(eigvals(A)) tr(Abig) sum(eigvals(Abig)) A = [1 1 -2 4] eigvals(A) eigvals(A^4) X = eigvecs(A) X = X ./ X[1,:]' X′ = eigvecs(A^4) X′ = X′ ./ X′[1,:]' eigvals(inv(A)) sqrt.(eigvals(A)) # takes the square root (elementwise) of each eigenvalue Diagonal(sqrt.(eigvals(A))) # the diagonal matrix √Λ Asqrt = X * Diagonal(sqrt.(eigvals(A))) / X # the √A matrix Asqrt * Asqrt sqrt(A) sqrt(A) ≈ Asqrt