This is very similar in spirit to your other question, trying to numerically “verify” something that you can show using math.
This is a very unusual application, and it is not possible to help you more without some context.
Specifically, is this a homework problem?
As you noted, if you randomly generate an orthonormal matrix, it has a 0 (theoretically, maybe near-0
numerically) chance of being triangular. Your approach is conceptually similar to
while true
r = randn()
if iszero(r)
@info r^2 == r # verify that 0*0 == 0 numerically
end
end