Math 291: Intro to Mathematica (for Linear Algebra)

with dusty wilson, mathematics instructor, highline community college
week 2

Contents

- Review entering and manipulating matrices
- Write more primative function to add matrices (use a clean notebook)
- Write more primative function to multiple matrices (use a clean notebook)

A Handy Bit of Code

A={{1,2},{3,4}} (*enter as a list of lists*)

A//MatrixForm (*express in our usual notation*)

$Post:=If[MatrixQ[#],MatrixForm[#],#]& (*outputs all matrices in MatrixForm (very slick, copy and don't memorize*)

A

Linear Algebra

Example 1: Review of manipulating matrices

A

A[[2,1]] (*extract and element*)

A[[2]] (*extracts the second row*)

A[[{2,1,2}]] (*extract multiple rows*)

A[[All,2]](*extracted the second column*)

Transpose[{A[[All,2]]}] (*expresses the extracted 2nd row as a column*)

Transpose[A](*switches rows and columns*)

Det[A] (*finds the determinant of a square matrix*)

Dimensions[A][[2]] (*the dimensions of a matrix*)

Example 2: Adding Matrices

a.) Matrices are added by adding entries in equivalent locations.  This is a good chance to learn the function Table and/or Array (much cleaner).

A+B

See the 2nd notebook for this week

Example 3: Multiplying Matrices

a.) Write a command to multiply the matrices G and H together.  This is a good chance to learn the functions: Array and Dimensions

(H={{9,8,7,6},{5,4,3,2},{1,3,5,9}})
G.H

See the 3rd notebook for this week.