I would like to practice the algorithm for the transformation from a matrix to its jordan normal form (with change of basis).
To do so, I wrote this script that generates random $n \times n$ matrices, with $n \in \{2,3,4,5\}$
import random, numpy n = random.randint(2,5) matrix = [] for i in xrange(n): line = [] for j in xrange(n): line.append(random.randint(-10, 10)) matrix.append(line) A = numpy.matrix(matrix) print("Here is your %i x %i Matrix" % (n, n)) print(A)
This way of generating random matrices isn't very good for the following reasons:
- The numbers can get really ugly (example)
- Sometimes it is not possible to calculate the decomposition of the matrix (example)
Do you know either pages with many examples of "good" matrices up to $5 \times 5$ or do you know how to change my script?