home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / DERIVE.ZIP / MATRIX.MTH < prev    next >
Encoding:
Text File  |  1989-07-28  |  2.2 KB  |  98 lines

  1. ; Generate a table of squares and cubes
  2. VECTOR([x,x^2,x^3],x,1,8)
  3.  
  4. ; Define MATRIX for generating matrices
  5. MATRIX(z,i,m,j,n):=VECTOR(VECTOR(z,j,1,n),i,1,m)
  6.  
  7. ; Generate a 2 by 3 matrix
  8. MATRIX(i-j,i,2,j,3)
  9.  
  10. ; Generate the 3 by 3 identity matrix
  11. IDENTITY_MATRIX(3)
  12.  
  13. ; Element [1,2] of a matrix
  14. ELEMENT([[a, b, c], [1, 2, 3]],1,2)
  15.  
  16. ; Row 2 of a matrix
  17. ELEMENT([[a, b, c], [1, 2, 3]],2)
  18.  
  19. ; Matrix addition and multiplication by scalar
  20. 2*[[a, 2], [3, b]]+[[1, 3], [a, -b]]
  21.  
  22. ; Dot product (inner product) of two vectors
  23. [2, a, 5].[2*a, 3, -1]
  24.  
  25. ; Dot product of two matrices
  26. [[a, b], [c, d]].[[x], [y]]
  27.  
  28. ; Cross product of two vectors
  29. CROSS([1, 2, 3],[a, b, c])
  30.  
  31. ; Number of elements of a vector
  32. DIMENSION([a, b, c])
  33.  
  34. ; Number of rows of a matrix
  35. DIMENSION([[1, 2, 3], [4, 5, 6]])
  36.  
  37. ; Define OUTER to compute the outer product
  38. OUTER(v,w):=VECTOR([ELEMENT(v,i)],i,DIMENSION(v)).[w]
  39.  
  40. ; The outer product of two vectors
  41. OUTER([a, b, c], [2, 3, 4])
  42.  
  43. ; Transpose of a matrix
  44. [[a, b, c], [1, 2, 3]]`
  45.  
  46. ; Column 3 of a matrix
  47. ELEMENT([[a, b, c], [1, 2, 3]]`,3)
  48.  
  49. ; Determinant of a square matrix
  50. DET([[2, 3], [a, b]])
  51.  
  52. ; Try factoring this determinant
  53. DET [[1, a, a, a], [1, x, a, a], [1, a, x, a], [1, a, a, x]]
  54.  
  55. DET [[x, 1, 1, 1, 1], [1, x, 1, 1, 1], [1, 1, x, 1, 1], [1, 1, 1, x, 1], [1, 1, 1, 1, x]]
  56.  
  57. ; Sum of the elements on the main diagonal
  58. TRACE([[a, b], [1, 2]])
  59.  
  60. ; Matrix inverse
  61. [[a, b], [2, 3]]^(-1)
  62.  
  63. ; A matrix dotted with its inverse is an identity matrix
  64. [[a, b], [c, d]].[[a, b], [c, d]]^(-1)
  65.  
  66. ; Using an inverse matrix to solve the system  a x + b y = e,  c x + d y = f
  67. [[a, b], [c, d]]^(-1).[[e], [f]]
  68.  
  69. ; Reduce matrices to row echelon form
  70. ROW_REDUCE([[2, 4], [3, 6]], [[6], [9]])
  71.  
  72. ; Characteristic polynomial of a square matrix
  73. CHARPOLY([[a, b], [b, a]],z)
  74.  
  75. ; Eigenvalues of a square matrix
  76. EIGENVALUES([[a, b], [b, a]])
  77.  
  78. ; Vector algebra simplification
  79. a.(b+c)-(b`.a`)`
  80.  
  81. ; Gradient of an expression
  82. GRAD(x+y^2+z^3)
  83.  
  84. ; Divergence of a vector
  85. DIV([1, 2*y, 3*z^2])
  86.  
  87. ; Divergence of the gradient of an expression
  88. LAPLACIAN(x+y^2+z^3)
  89.  
  90. ; Curl of a vector
  91. CURL([y^2, 2*x*z, 0])
  92.  
  93. ; Scalar potential of a vector
  94. POTENTIAL([1, 2*y, 3*z^2])
  95.  
  96. ; Vector potential of a vector
  97. VECTOR_POTENTIAL([-2*x, 0, 2*z-2*y])
  98.