Calculating with Vectors and Matrices
Adding or Subtracting Vectors
Adding or Subtracting Matrices
Scalar Multiplication
Matrix Multiplication
Element-by-Element Operations
Transpose, Determinant, Inverse
Array Functions
Array operations such as addition or multiplication require that certain conditions are met and that certain procedures are followed.
Adding or Subtracting Vectors
You may add or subtract two vectors whenever they are the same length.
This works:
This doesn't:
Adding or Subtracting Matrices
Here are two 2 x 2 matrices, S and T:
Now add them together:
The rule for matrix addition is that when you add two matrices together, the resultant matrix is another matrix, the elements of which are the sums of those same elements of the two original matrices. Just as with vectors, matrix addition is only defined for matrices of the same size.
Scalar Multiplication
If you multiply a vector by a scalar (single number), the result is a vector in which each component of the original vector has been multiplied by the scalar.
Matrix Multiplication
The inside dimensions of the arrays to be multiplied must be equal. The outside dimensions determine the size of the product matrix.

C = A*B is the linear algebraic product of the matrices A and B. More precisely,
For non scalar A and B, the number of columns of A must equal the number of rows of B. A scalar can multiply a matrix of any size.
This does not work.
The number of columns in matrix D (3) is not the same
as the number of rows in vector V (1).
This works.
The numbers of columns in matrix D is the same as
the number of rows in vector P.
Element-by-Element Operations - Vectorize Operator
Sometimes you do not want true matrix multiplication. Instead you want each element of the first matrix multiplied by corresponding element of the second, for example. Element-by-element operations are available in Mathcad by means of the vectorize operator (from the Matrix Toolbar). The vectorize operator changes the meaning of operators and functions so that they apply to every element of an array. This allows you to perform calculations in parallel.

The arrays must be the same size for element-by-element operations.
Compute the element by element (or Hadamard) product of A and B. Also compute the element by element product of A with itself.
Note that these are not the same as the corresponding ordinary matrix products:
Another example: here is B raised to the Ath power, computed
element by element:
Many functions and operators automatically perform operations on the elements of arrays so you do not always have to use the vectorize operator. Use the vectorize operator primarily when a function or operator has a special meaning for arrays. For instance multiplication has a special meaning for arrays and that meaning is used by default. The vectorize operator has to be used to force an element-by-element multiplication
This does not work. The natural logarithm is not defined for matrices, so element-by-element mathematics is required for this problem. Use the vectorize operator (from the Matrix Toolbar) over the entire expression to tell Mathcad to use element-by-element mathematics.
Transpose, Determinant, Inverse
Here is a 3 x 3 matrix, C:
To calculate the transpose of the matrix, type “C[Ctrl]1”.
To calculate the determinant of the matrix, type “C^|”.
To calculate the inverse of the matrix, type “C^-1”.
A square matrix C has an inverse C-1 if the determinant of C is not equal to zero. A matrix possessing an inverse is called nonsingular or invertible. A matrix which does not have an inverse is called singular.
This does not work because
matrix T is singular.
Array Functions
Mathcad includes a variety of functions for working with vectors and matrices. A few are listed below. For a full list, choose Function from the Insert menu and click on the Vector and Matrix category.
the maximum or minimum of the elements in a vector or matrix
the number of rows or columns in
sorts a vector in ascending order
rearranges the rows of a matrix so that the -th column is in ascending order
gives the n x n identity matrix
combines two matrices together by placing them side by side
combines two matrices by stacking above
^ Top