DEV Community

Vinod V
Vinod V

Posted on • Originally published at forem.julialang.org

Idempotent matrices in Julia

Let AA be a square matrix of order nn . Then AA is called an idempotent matrix if AA=AAA = A .

If a matrix AA is idempotent, it follows that An=A,nNA^n = A, \forall n \in \mathbb{N} . Idempotent matrices behave like identity matrices when raised to a power nn . All Idempotent matrices except identity matrices are singular matrices.

One way to make idempotent matrices is A=IuuTA = I - u u^T , where uu is a vector satisfying uTu=1u^T u = 1 . In this case AA 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)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)