linalg.txt 672 B

1234567891011121314151617181920212223242526272829303132333435
  1. %%%%%%%%%%%%%%%%%%%%%
  2. % LINEAR ALGEBRA
  3. %%%%%%%%%%%%%%%%%%%%%
  4. % Enable fancy output for easier viewing of
  5. % matrix output
  6. %fancy_output$
  7. % Load linear algebra package
  8. load_package linalg$
  9. % Define a complex 3x3 matrix
  10. m1 := mat((1+i*3, 2-i*5, 7-i), (4-i*2, 6+i*9,-8+i*4), (-3-i*7, 3+i*2, -1+i*6));
  11. % Determinant of matrix
  12. write "|m1| = ", det(m1)$
  13. % Trace of matrix
  14. write "trace(m1) = ", trace(m1)$
  15. % Characteristic polynomial
  16. write "characteristic polynomial of m1:";
  17. char_poly(m1,eta);
  18. % Enable real arithmetic
  19. on rounded$
  20. % Singular value decomposition of a matrix.
  21. a := mat((1,3),(-4,3));
  22. write "Singular Value Decomposition of a:"$
  23. svd(a);
  24. off rounded;
  25. end;