Vectors and Matrices


SUBMITTED BY: smart4two

DATE: Jan. 1, 2018, 12:21 p.m.

FORMAT: Text only

SIZE: 2.0 kB

HITS: 112

  1. Vectors and Matrices
  2. You can use lists to generate matrices and vectors. We can think of
  3. list as a vector or a row of a matrix. A list of lists is then a two
  4. dimension array of objects, like a m x n matrix.
  5. In order to represent a two component vector you type in,
  6. In[1]:= {x,y}
  7. Out[1]= {x, y}
  8. To represent a 2 x 2 matrix,
  9. In[2]:= {{1,2},{3,4}} //MatrixForm
  10. 1 2
  11. Out[2]//MatrixForm= 3 4
  12. The //MatrixForm displays the list in a matrix form.
  13. You can also perform vector and matrix operations. For example, a
  14. scalar or dot product of vectors or multiplication of two matrices.
  15. In[3]:= v = {x,y}
  16. Out[3]= {x, y}
  17. In[4]:= v . v
  18. 2 2
  19. Out[4]= x + y
  20. In[5]:= A = {{1,2},{3,4}}
  21. Out[5]= {x, y}
  22. In[7]:= A . A
  23. Out[7]= {{7, 10}, {15, 22}}
  24. The following are some standard functions used for vectors in
  25. Mathematica.
  26. Table[f,{i,n}] builds a vector of length 'n' by evaluating
  27. 'f' with i=1, i=2,..., i=n.
  28. Array[a,n] builds a vector of length 'n' of the form
  29. {a[1],a[2],....}
  30. Range[n] create a list {1,2,3,...,n}
  31. list[[i]] gives the ith element in list
  32. Length[list] gives the length of the list
  33. //Columnform displays the list in column form
  34. Similar commands which are applicable to matrices are given below.
  35. Table[f,{i,m},{j,n}] builds a m x n matrix, evaluating 'f'
  36. with 'i' and 'j' ranging from 1 to m
  37. and 1 to n respectively.
  38. Array[a,{m,n}] builds an m x n matrix with elements
  39. a[i,j] with 'i' ranging from 1 to m
  40. and 'j' ranging from 1 to n.
  41. IdentityMatrix[n] generates a n x n identity matrix.
  42. DiagonalMatrix[list] creates a diagonal matrix with
  43. elements of the list along its
  44. diagonal.
  45. list[[i]] gives the ith row of the matrix.
  46. list[[i,j]] gives the i,jth element of the matrix.
  47. Dimensions[list] gives the dimension of a matrix
  48. represented by the list.
  49. MatrixForm[list] displays the list in a matrix form.

comments powered by Disqus