Idempotent matrices in Julia

Hi all,
I have created a small blog post related to Idempotent matrices with Julia.
Idempotent matrices in Julia
Please provide your feedback.

3 Likes

You could show that rank(A)=tr(A)=4.

Here is another direction: What if you wanted to have a rank 3 idempotent matrix? How would you find a vector v such that u'*v = 0 so that we can make a B with rank(B) = 3 and B^100 ≈ B?

1 Like

Very nice. I like your 100 Julia Excercises too!

I feel the sentence

Idempotent matrices behave like identity matrices when raised to a power n

is a bit misleading. They do only after being applied once.

I think your example demonstrates Julia’s natural math syntax nicely and if that’s all you want, then I say well done.

If you want to go a step further and showcase what Julia can do, you could define a IdempotentMatrix<:AbstractMatrix type and specialize all kinds of linear algebra on it. Most importantly of course matrix powers, but also eigenvalues, trace, determinant…
I admit that I’ve thought about this for approximately five minutes, so maybe there is good reason not to :smiley:

2 Likes

What would be a correct sentence which will clearly show the behaviour of idempotent matrices when raised to a power?

I think P^2 = P explains it tbh.

2 Likes

I’m with @jacobusmmsmit in this. The definition is perfectly understandable. IMHO the sentence could be left out entirely.

Cross posted to Idempotent matrices in Julia - Julia Community