Linear Algebra

Dennis Silverman
Mathematical Physics 212A
Department of Physics and Astronomy
U.C. Irvine

Vectors

Vectors are given as lists

v := {a, b, c}

w := {x, y, z}

k v

v + w

Functions are applied to each element in a vector
Scalar Dot Product

v.w

Vector element

v[[3]]

Ways to generate vectors

Array[d, 6]

Table[i + 6, {i, 5}]

Matrices

Matrices are given by

m = {{m11, m12}, {m21, m22}}

MatrixForm[m]

To generate a matrix

A := Array[f, {3, 3}]

MatrixForm[A]

T := Table[3 i - 3 + j, {i, 3}, {j, 3}]

H := MatrixForm[T]

H

d := DiagonalMatrix[{a1, a2, a3}]

MatrixForm[d]

iden := IdentityMatrix[3]

MatrixForm[iden]

MatrixForm[Transpose[T]]

T

T[[2, 3]]

Third row

T[[3]]

Third column

Transpose[T][[3]]

Range[10]

Matrix multiplication

m

p := {{p11, p12}, {p21, p22}}

MatrixForm[m.p]

Matrix products with vectors

x := {x1, x2}

MatrixForm[m.x]

MatrixForm[x.m]

y := {y1, y2}

x.m.y

Inverse[m]

Det[m]

Det[T]

The trace is given by the sum over diagonal elements

tr := 
      (∑_(i = 1)^3) T[[i, i]]

tr

Eigenvalues and Eigenvectors

Eigenvalues[T]

evt := Eigenvectors[T]

evt

<< "LinearAlgebra`Orthogonalization`"

nevt := N[evt]

nevt

GramSchmidt[nevt]

Normalize[nevt[[1]]]

Projection[nevt[[1]], 
      nevt[[2]]]

cp := CharacteristicPolynomial[T, eig]

cp

Roots[cp == 0, eig]

Factor[cp]

m

Linear Equations m x = vec

?LinearSolve

vec := {vec1, vec2}

LinearSolve[m, vec]