VectorMatrixEquations.mw

Math 22 Fall 2004

Linear Algebra with Applications


Vector and Matrix Equations

September 29, 2004

    Load the package for doing Linear Algebra

> with(Student[LinearAlgebra]):

Warning, the protected name . has been redefined and unprotected

Example 1: Solve a vector equation

x1*a1 + x2*a2 = b

> a1 := <-1, 3, -2>: a2 := <3, 2, -3>: b := <5, -4, 1>:
a1, a2, b;

Vector[column]([[-1], [3], [-2]]), Vector[column]([[3], [2], [-3]]), Vector[column]([[5], [-4], [1]])

     Define an (augmented) matrix of the equation

> A := <a1 | a2 | b>;

A := Matrix([[-1, 3, 5], [3, 2, -4], [-2, -3, 1]])

    Reduce it to an echelon form

> A := AddRow(A, 2, 1, 3):
A := AddRow(A, 3, 1, -2);

A := Matrix([[-1, 3, 5], [0, 11, 11], [0, -9, -9]])

> A := MultiplyRow(A, 2, 1/11):
A := AddRow(A, 3, 2, 9);

A := Matrix([[-1, 3, 5], [0, 1, 1], [0, 0, 0]])

    ... and to the reduced echelon form

> A := AddRow(A, 1, 2, -3);

A := Matrix([[-1, 0, 2], [0, 1, 1], [0, 0, 0]])

    Solve the system now

> x := LinearSolve(A);

x := Vector[column]([[-2], [1]])

    Test our solution

> x[1] * a1 + x[2] * a2 = b;

Vector[column]([[5], [-4], [1]]) = Vector[column]([[5], [-4], [1]])

Example 2: Solve a matrix equation Ax=b

> A := <<1, 3, -2> | <2, -1, 3> | <-2, -3, 1>>:
b := Vector(3, symbol = v):

M := <A | b>:

A, b, M;

Matrix([[1, 2, -2], [3, -1, -3], [-2, 3, 1]]), Vector[column]([[v[1]], [v[2]], [v[3]]]), Matrix([[1, 2, -2, v[1]], [3, -1, -3, v[2]], [-2, 3, 1, v[3]]])

    Solve this system

> M := AddRow(M, 2, 1, -3):
M := AddRow(M, 3, 1, 2);

M := Matrix([[1, 2, -2, v[1]], [0, -7, 3, v[2]-3*v[1]], [0, 7, -3, v[3]+2*v[1]]])

> M := AddRow(M, 3, 2, 1);

M := Matrix([[1, 2, -2, v[1]], [0, -7, 3, v[2]-3*v[1]], [0, 0, 0, v[3]-v[1]+v[2]]])

   Conclusion: this system is not consistent for every b

    It is easy to find v1, v2, v3 such that v3-v1+v2 is nonzero

>