Idempotent matrices in Julia

Let be a square matrix of order . Then is called an idempotent matrix if .

If a matrix is idempotent, it follows that . Idempotent matrices behave like identity matrices when raised to a power . All Idempotent matrices except identity matrices are singular matrices.

One way to make idempotent matrices is , where is a vector satisfying . In this case is symmetric too.

#Idempotent matrices in Julia
using LinearAlgebra
u = rand(5)
u = u/norm(u) #Force u^T * u = 1
A = I - u*u'
isapprox(A^100,A) # true
isequal(A,A') # true (test for symmetricity)

Comments

Popular posts from this blog

100 Julia exercises with solutions

Book Review : Python Programming Exercises, Gently Explained