The first part of this tutorial is devoted to matrix algebra---topis that will be used to solve and analyze linear and nonlinear systems of ordinary differential equations.

Return to computing page for the first course APMA0330
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 first course APMA0330
Return to the main page for the second course APMA0340
Introduction to Linear Algebra with Mathematica

The main objective of this chapter is to define a function of a square matrix. Specifically, suppose that A is a square matrix and f(λ) is an admissible function (this term will be clarified later) of real or complex variable λ. Although Mathematica has a deficated command MatrixFunction, this chapter presents several approaches to define a matrix function f(A). For example, the following script can be used to build a matrix function for \( F(\lambda ) = \sin \left( \sqrt{\lambda}\,t \right) / \sqrt{\lambda} \) and 3-by-3 matrix:

B = {{4, 3, 3}, {-9, -53, -39}, {12, 75, 55}} (* define matrix *)
F[x_] = Sin[Sqrt[x]*t]/Sqrt[x] (* define function *)
MF = MatrixFunction[F, B] (* required matrix function *)
MF[[All, 1]] (* extract first column *)


The topics to be covered in this chapter:

1.1: How to define vectors

This section presents basic definitions and operations with vectors, including dot product, inner product, and vector product.

1.2: How to define matrices

Understanding matrices is crucial for almost all applications, especially for computer modeling. Indeed, a laptop or smartphone monitor is the most common example of a matrix filled with pixels. A wide range of applications includes the numerical solution of a set of linear algebraic equations. All numerical algorithms for solving differential equations are based on utilization of solution to the algebraic matrix problems. Every matrix can be considered as an array or vector with entries being again arrays. So a matrix is next generalization of a vector. In this section, you will learn how to define matrices with Mathematica as well as some other manipulation tools.

1.3: Basic operations with matrices

In this section, you will learn how to execute the basic arithmetic operations (addition, subtraction, and multiplication) with matrices as well as some other matrix manipulation tools.

1.4: Linear systems of equations

This auxiliary section reminds the reader when system of linear algebraic equations has a solution. Such systems are called consistent.

1.5: Determinants and inverses

The determinant is a special scalar-valued function defined on the set of square matrices. Although it still has a place in many areas of mathematics and physics, our primary application of determinants is to define eigenvalues and characteristic polynomials for a square matrix A. Because of difficulties with motivation, intuitiveness, and simple definition, there is a tendency in exposition of linear algebra without classical involvement of determinants.

1.6: Special matrices

This section presents a collection of special matrices that are very usefule in many approcations.

1.7: Eigenvalues and Eigenvectors

An eigenvector of a linear transformation is a non-zero vector that changes by only a scalar factor when that linear transformation is applied to it. This scalar factor is called the eigenvalue. Every nontrivial matrix has an eigenvalue and corresponding eigenvector.

1.8: Diagonalization procedure

This section presents a classical approach to define a functions of a matrix via diagonalization procedure. If a matrix is diagonalizable, all operations with it can be reduced to corresponding operations with its eigenvalues.

1.9: Sylvester formula

The most efficient formula to define a matrix function using Sylvester's auxiliary matrices. This section deals only with diagonalizable matrices.

1.10: The resolvent method

The most powerful method to define a matrix function independently whether the matrix is diagonalizable or not.

1.11: Polynomial interpolation

Another powerful technique for defining matrix functions based on knowledge of its minimal or characteristic polynomial.

1.12: Positive matrices

This section presents positive definite matrices in slightly different way from classical approach.

1.13: Roots

Four previously introduced methods to define matrix functions (diagonalization, Sylvester's formula, the resolvent method, and polynomial interpolation) are applied to find square roots of matrices.


  1. Frame, J.S., Matrix functions and applications, Reprint from March-July, 1964 issues of IEEE Spectrum. Parts II and IV.
  2. Gantmacher, F.G., The Theory of matrices, Vol. 1, Chelsea Publishing Company, New York, 1959.
  3. Hale, N., Higham, N.J., and Trefethen, L.N., Computing Aα, log(A), and related matrix functions by contour integrals, SIAM Journal on Numerical Analysis, Vol. 46, No. 5, 2505-2523. 2008.
  4. Ikebe, Y. and Inagaki, T., An elementary approach to the functional calculus for matrices, The American mathematical Monthly, 1986, Vol. 93, No. 3, pp. 390--392.
  5. Schmelzer, T., and Trefethen, L.N., Evaluating matrix functions for exponential integrators via Carathéodory-Fejér approximation and contour integrals, ETNA, 2007, Volume 29, 1-18, 2007.
  6. Shiskowski, K. and Frinkle, K., Principles of Linear Algebra with Mathematica, Wiley, 2011. ISBN: 978-0-470-63795-1
  7. "Nonlinear Physics with Mathematica for Scientists and Engineers," by Richard H. Enns, George C. McGuire Birkhäuser; 2001 edition (June 26, 2001) ISBN-10: 0817642234 ISBN-13: 978-0817642235
  8. Matrix Calculator