1
$\begingroup$

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?

  • 0
    I don't know how yo$u$'d do it in n$u$mpy, but one approach would be to build up a matrix with known Jordan block structure and then perform a similarity transformation with an orthogonal or unimodular matrix.2012-08-08

1 Answers 1

4

You could generate a Jordan normal form $J$ randomly, then an invertible matrix $X$ randomly and have the algorithm compute $Y=XJX^{-1}$ for you. $Y$ would be your exercise.

  • 0
    Thanks for your answer rschwieb. I've created this script: https://gist.github.com/32839522012-08-08