Julia Community 🟣

Vinod V
Vinod V

Posted on • Updated on • Originally published at pythonjulia.blogspot.com

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,∀n∈NA^n = A, \forall n \in \mathbb{N} . All Idempotent matrices except identity matrices are singular matrices.

One way to make idempotent matrices is A=I−uuTA = 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

Cross posted to https://pythonjulia.blogspot.com/2022/03/100-julia-exercises-with-solutions.html

Latest comments (7)

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
sindoudedv profile image
Sindou KONE

Add to the discussion

Collapse
 
logankilpatrick profile image
Logan Kilpatrick

Hey! This is cool to see, it would be nice to also add some context for folks about why you would need this, etc etc. You can also set the canonical URL if you edit this post to point to the original blog post above.

Collapse
 
vinodv profile image
Vinod V

You can also set the canonical URL if you edit this post to point to the original blog post above.
How to do it.

Collapse
 
logankilpatrick profile image
Logan Kilpatrick

I went ahead and fixed it for you, but next to the publish button there's a blue circle-ish thing, that's where you can set the canonical URL.