Genius Wiki

Recent site activity

Useful GEL code for teaching

Cut and paste the code into a new program and hit "Run" in the GNOME version.

Eigenvalue examples


Here is a bit of code to find 3 by 3 integer matrices with specific eigenvalues.  A will be a matrix with eigenvalues 1,2,3 and columns of E will be the corresponding eigenvectors.

# Start with the eigenvalues
D = diag(1,2,3);
do (
  # Find some eigenvectors
  do (
    E = randint(11,3,3) - 5*ones(3,3)
  ) while det(E) == 0;
  # Make the matrix
  A = E*D*E^-1;
) while not IsMatrixInteger(A);
# print A
A

Row reduction examples

Here is a bit of code to find random 3 by 4 matrices with reduced row echelon form (rref) with only integer entries.  The entries of the matrix are between -5 and 5.

# Find random 3 by 4 integer matrices
# with integer rref form
do (
  A = randint (11,3,4) - 5*ones(3,4)
) while not IsMatrixInteger(rref(A));
# print A
A
# print rref(A)
rref(A)

Row reduction examples with free variables

Here is a bit of code to find random 3 by 4 matrices with reduced row echelon form (rref) with only integer entries.  The entries of the matrix are between -5 and 5.  Furthermore the rref form will have a zero row, so probably will be a consistent system with some free variables.

# Find random 3 by 4 integer matrices
# with integer rref form with a zero row
# in rref
do (
  A = randint (11,3,4) - 5*ones(3,4)
) while not IsMatrixInteger(rref(A)) or CountZeroColumns(rref(A).') == 0;
# print A
A
# print rref(A)
rref(A)