Preface
This is a tutorial made solely for the purpose of education and it was designed for students taking Applied Math 0340. It is primarily for students who have some experience using Mathematica. If you have never used Mathematica before and would like to learn more of the basics for this computer algebra system, it is strongly recommended looking at the APMA 0330 tutorial. As a friendly reminder, don'r forget to clear variables in use and/or the kernel.
Finally, the commands in this tutorial are all written in bold black font, while Mathematica output is in regular fonts. This means that you can copy and paste all comamnds into Mathematica, change the parameters and run them. You, as the user, are free to use the scripts to your needs for learning how to use the Mathematica program, and have the right to distribute this tutorial and refer to this tutorial as long as this tutorial is accredited appropriately.
Return to computing page for the second course APMA0340
Return to Mathematica tutorial for the first course APMA0330
Return to Mathematica tutorial for the second course APMA0340
Return to the main page for the course APMA0340
Return to the main page for the course APMA0330
Return to Part I of the course APMA0340
Basic Matrix Operations
Both a vector and a matrix can be multiplied by a scalar; with the operation being *. Matrices and vectors can be added or subtracted only when their dimensions are the same.
The dot product of any two vectors of the same dimension can be done with the dot operation given as Dot[vector 1, vector 2] or with use of a period “. “ .
Now we start working with matrices. A period “.” can also be used for matrix multiplication between one matrix and a vector or two matrices. It is important to note that when doing matrix multiplication an (m x n) matrix can only be multiplied by an (n x s) where m, n, and s are whole numbers.
The cross product can be done on two vectors. It is important to note that the cross product is an operation that is only functional in three dimensions. The operation can be computed using the Cross[vector 1, vector 2] operation or by generating a cross product operator between two vectors by pressing [Esc] cross [Esc]. ([Esc] refers to the escape button)
To find the Euclidean length of a vector use the Norm[vector] operation. The command Norm[ ] also works for finding the norm of a complex number, where the imaginary part is represented by “I.”
This definition can be extended to matrices:
Mathematica knows what vector should be used when a matrix is multiplied by a vector. For example,
v={1,2};
A.v
Example 2.1.1: Write the vector \( {\bf a}=2{\bf i}+3{\bf j}-4{\bf k} \) as the sum of two vectors, one parallel, and one perpendicular to the vector \( {\bf b}=2{\bf i}-{\bf j}-3{\bf k} .\)
We find the parallel vector:
b = {2, -1, -3}
madB2 = (b[[1]])^2 + (b[[2]])^2 + (b[[3]])^2
Aparallel = a.b/madB2*b
Example 2.1.2: Let a=<1,3,-4> and b=<-1,1,-2> be two vectors. Find \( {\bf a}\cdot ({\bf a}\times {\bf b}), \) where \( {\bf a}\cdot {\bf b} \) is dot product, and \( {\bf a}\times {\bf b} \) is cross product of two vectors. Input variables are vecors a and b. Function will calculate the cross product of a and b, and then calculate the dot product of that value and a. Notice that any input values for a and b will result in zero sum.
b={-1,1,-2}
c=a.Cross[a,b]
{-1,1,-2}
0
We don't know exactly who when the multiplication of matrices was invented. At least we know that the work of 1812 by Jacques Philippe Marie Binet (1786--1856) contains the definition of the product of matrices. Let A be a \( m \times n \) matrix and B be a \( n \times k \) matrix. Its product, a \( {\bf C} = {\bf A}\,{\bf B} \) is a \( m \times k \) matrix, in which the n entries across the rows of A are multiplied with the n entries down the columns of B:
How to define Vectors
How to define Matrices
Basic Operations with Matrices
Linear Systems of Equations
Determinants and Inverse Matrices
Special Matrices
Eigenvalues and Eigenvectors
Generalized Eigenvectors
Diagonalization Procedure
Sylvester Formula
The Resolvent Method
Spectral Decomposition Method
Positive Matrices
Roots
Miscellaneous
Return to Mathematica page
Return to the main page (APMA0330)
Return to the Part 1 Matrix Algebra
Return to the Part 2 Linear Systems of Equations
Return to the Part 3 Linear Systems of Ordinary Differential Equations
Return to the Part 4 Non-linear Systems of Ordinary Differential Equations
Return to the Part 5 Numerical Methods
Return to the Part 6 Fourier Series
Return to the Part 7 Partial Differential Equations