Linear Algebra

MA 237 Chapter 3 Homework Solutions

Richard Hitt

Homework Exercises

Here are the four On Line exercises from section 3.4 in the text translated in Mathematica.

Exercise 1

Let A be the matrix from exercise 2a on page 177.  Use  LinearSolve to solve the system A.X=B where

B = Transpose[{{2.1, 3.2, -4.4}}]

Solution

A = {{1, 0, 3}, {4, 4, 2}, {2, 5, -4}}

LinearSolve[A, B]

If you want to check the solution, you can do

A . LinearSolve[A, B] == B

Exercise 2

Read the exercise in the text on page 182 and solve it in Mathematica.

B2 = Transpose[{{2.1, 3.21, -4.4}}]

LinearSolve[A, B2]

Errorvector = LinearSolve[A, B2] - LinearSolve[A, B]

So the first component has the largest error.  To see why, note that the Errorvector can be obtained algebraically by

Inverse[A] . (B2 - B)

So if we look at the inverse of A

Inverse[A] // MatrixForm

and B2-B

(B2 - B) // MatrixForm

we see that the only entries in Inverse[A] the affect the outcome of the multiplication are those in the second column.  Since the largest of those is in the first row, the first component in the result is changed the most.

Inverse[A] // MatrixForm

In order to see how accurately the values of B must be measured to ensure that the computed values of X are all within 0.001 of the correct values, we can view the problem geometrically.  Look at the cube centered at the origin with edge lengths that extend plus or minus 0.001 units from 0.

{Polygon[{{ .001,  .001,  .001}, { .001,  .001, - .001}, { .001, - .001, - .001}, { .001, - .001,  .001}}], 
Polygon[{{- .001,  .001,  .001}, {- .001,  .001, - .001}, {- .001, - .001, - .001}, {- .001, - .001,  .001}}], 
Polygon[{{ .001,  .001,  .001}, {- .001,  .001,  .001}, {- .001, - .001,  .001}, { .001, - .001,  .001}}], 
Polygon[{{ .001,  .001, - .001}, {- .001,  .001, - .001}, {- .001, - .001, - .001}, { .001, - .001, - .001}}], 
Polygon[{{ .001,  .001,  .001}, {- .001,  .001,  .001}, {- .001,  .001, - .001}, { .001,  .001, - .001}}], 
Polygon[{{ .001, - .001,  .001}, {- .001, - .001,  .001}, {- .001, - .001, - .001}, { .001, - .001, - .001}}]
};
Show[Graphics3D[%], Axes -> True]

We want to know what shape in 3-space lands on this cube under the matrix transformation Inverse[A].  We can find that shape simply by applying A to the vertices of this cube.

{Polygon[
          Transpose[
            A . Transpose[{{ .001,  .001,  .001}, { .001,  .001, - .001}, { .001, - .001, - .001}, { .001, - .001,  .001}}]]], 
Polygon[
          Transpose[
            A . Transpose[{{- .001,  .001,  .001}, {- .001,  .001, - .001}, {- .001, - .001, - .001}, {- .001, - .001,  .001}}]]], 
Polygon[
          Transpose[
            A . Transpose[{{ .001,  .001,  .001}, {- .001,  .001,  .001}, {- .001, - .001,  .001}, { .001, - .001,  .001}}]]], 
Polygon[
          Transpose[
            A . Transpose[{{ .001,  .001, - .001}, {- .001,  .001, - .001}, {- .001, - .001, - .001}, { .001, - .001, - .001}}]]], 
Polygon[
          Transpose[
            A . Transpose[{{ .001,  .001,  .001}, {- .001,  .001,  .001}, {- .001,  .001, - .001}, { .001,  .001, - .001}}]]], 
Polygon[
          Transpose[
            A . Transpose[{{ .001, - .001,  .001}, {- .001, - .001,  .001}, {- .001, - .001, - .001}, { .001, - .001, - .001}}]]]
};
Show[Graphics3D[%], Axes -> True, 
      AxesLabel -> {x, y, z}]

This shape represents all the points in 3-space for the B2 vector that get mapped under Inverse[A] to a vector with all coordinates within 0.001 of 0.  So we can just look at

A . {{- .001}, {- .001}, { .001}}

to see that the measured values of the components of B must be accurate to within 0.002 in the first coordinate, 0.006 in the second, and 0.011 in the third.

Exercise 3

Again, read the problem and solve in Mathematica.  Be sure to enter the matrix using fractions rather than decimals to maintain the exactness in the calculations.

Solution

Clear[A, B, B2];
A = {{1, 1/2, 1/3}, {1/2, 1/3, 1/4}, {1/3, 1/4, 
            1/5}};
A // MatrixForm

B2 = {{82.9}, {46.07}, {31.3}}
B = {{83}, {46}, {32}}
B - B2

We can obtain solutions with either LinearSolve or using Inverse[A]

sol = LinearSolve[A, B]
sol2 = LinearSolve[A, B2]

X = Inverse[A] . B
X2 = Inverse[A] . B2

We can calculate the percent error of X compared to X2.

percenterror = Abs[100*(X - X2)/X2]
numericalerror = X - X2

Note that the largest percent error occurs in the first entry while the largest numerical error occurs in the second entry.  If we look at Inverse[A] we can see why the errors are so large.

Inverse[A];
Inverse[A] // MatrixForm

The entries in Inverse[A] are large numbers, so any deviation in the B2 vector gets commensurately magnified.  That effect is compounded by the fact that the errors in measurement on B2 are oppositely signed on the second entry exploiting the sign changes along the three rows of Inverse[A].

In order to see how accurately the values of B must be measured to ensure that the computed values of X are all within 0.001 of the correct values, we can view the problem geometrically.  Look at the cube centered at the origin with edge lengths that extend plus or minus 0.001 units from 0.

{Polygon[{{ .001,  .001,  .001}, { .001,  .001, - .001}, { .001, - .001, - .001}, { .001, - .001,  .001}}], 
Polygon[{{- .001,  .001,  .001}, {- .001,  .001, - .001}, {- .001, - .001, - .001}, {- .001, - .001,  .001}}], 
Polygon[{{ .001,  .001,  .001}, {- .001,  .001,  .001}, {- .001, - .001,  .001}, { .001, - .001,  .001}}], 
Polygon[{{ .001,  .001, - .001}, {- .001,  .001, - .001}, {- .001, - .001, - .001}, { .001, - .001, - .001}}], 
Polygon[{{ .001,  .001,  .001}, {- .001,  .001,  .001}, {- .001,  .001, - .001}, { .001,  .001, - .001}}], 
Polygon[{{ .001, - .001,  .001}, {- .001, - .001,  .001}, {- .001, - .001, - .001}, { .001, - .001, - .001}}]
};
Show[Graphics3D[%], Axes -> True]

We want to know what shape in 3-space lands on this cube under the matrix transformation Inverse[A].  We can find that shape simply by applying A to the vertices of this cube.

{Polygon[
          Transpose[
            A . Transpose[{{ .001,  .001,  .001}, { .001,  .001, - .001}, { .001, - .001, - .001}, { .001, - .001,  .001}}]]], 
Polygon[
          Transpose[
            A . Transpose[{{- .001,  .001,  .001}, {- .001,  .001, - .001}, {- .001, - .001, - .001}, {- .001, - .001,  .001}}]]], 
Polygon[
          Transpose[
            A . Transpose[{{ .001,  .001,  .001}, {- .001,  .001,  .001}, {- .001, - .001,  .001}, { .001, - .001,  .001}}]]], 
Polygon[
          Transpose[
            A . Transpose[{{ .001,  .001, - .001}, {- .001,  .001, - .001}, {- .001, - .001, - .001}, { .001, - .001, - .001}}]]], 
Polygon[
          Transpose[
            A . Transpose[{{ .001,  .001,  .001}, {- .001,  .001,  .001}, {- .001,  .001, - .001}, { .001,  .001, - .001}}]]], 
Polygon[
          Transpose[
            A . Transpose[{{ .001, - .001,  .001}, {- .001, - .001,  .001}, {- .001, - .001, - .001}, { .001, - .001, - .001}}]]]
};
Show[Graphics3D[%], Axes -> True, 
      AxesLabel -> {x, y, z}]

This shape represents all the points in 3-space for the B2 vector that get mapped under Inverse[A] to a vector with all coordinates within 0.001 of 0.  So we can just look at

A . {{ .001}, { .001}, { .001}}

to see that the measured values of the components of B must be accurate to within 0.0018 in the first coordinate, 0.00108 in the second, and 0.00078 in the third.

Exercise 4

In this problem, you may find it useful to measure the magnitude of a vector (also called the norm).  You can build a function for doing this.

Clear[norm,  v]
norm[v_]  :=  Sqrt[Flatten[v] . Flatten[v]]

Now you can work the problem.

Solution part (a)

From Exercise 2, we have

A = {{1, 0, 3}, {4, 4, 2}, {2, 5, -4}}
B = Transpose[{{2.1, 3.2, -4.4}}]
B2 = Transpose[{{2.1, 3.21, -4.4}}]
X = LinearSolve[A, B]
X2 = LinearSolve[A, B2]

PX = 100*norm[X - X2]/norm[X]

PB = 100*norm[B - B2]/norm[B]

PX/PB

This shows that the percent error got magnified between the measured values of B and the computed values of X.  We would like this number to be small if we want to maintain the accuracy of the B measurement.

Solution to part (b)

From exercise 3, we have

Clear[A, B, B2];
A = {{1, 1/2, 1/3}, {1/2, 1/3, 1/4}, {1/3, 1/4, 1/5}}
B2 = {{82.9}, {46.07}, {31.3}}
B = {{83}, {46}, {32}}
X = LinearSolve[A, B]
X2 = LinearSolve[A, B2]

PX = 100*norm[X - X2]/norm[X]
PB = 100*norm[B - B2]/norm[B]
PX/PB

Solution to part (c)

The conditioning number of a square matrix A can be defined as

Cond[A_] := norm[A]*norm[Inverse[A]]

For the matrix in exercise 2, we have

A = {{1, 0, 3}, {4, 4, 2}, {2, 
            5, -4}};
Cond[A] // N

From exercise 3, we have

A = {{1, 1/2, 1/3}, {1/2, 1/3, 1/4}, {1/3, 1/4, 
            1/5}};
Cond[A] // N