Mathematica for linear algebra

Here is some mathematica code to be used by my linear algebra students. The post will be periodically updated as the course progresses.

Entering matrices

Mathematica views matrices as lists of columns. Thus to enter the matrix
\left(  \begin{array}{cccc}   1 & 1 & -1 & -1 \\   1 & 2 & 3 & 4 \\   1 & 3 & 5 & 7 \\  \end{array}  \right)
we type in

mat = {{1, 1, -1, -1}, {1, 2, 3, 4}, {1, 3, 5, 7}};

and hit [enter]. Here we have given the matrix the name mat and suppressed the output.

To view the matrix, type in the code


and hit [enter].

Row reducing a matrix

To row reduce the matrix, type in the code


and hit [enter]. Notice that the output is just given in list format. To display the result as a matrix, you can use either



RowReduce[mat] // MatrixForm
This entry was posted in Linear Algebra, Mathematica. Bookmark the permalink.

Leave a comment here

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s