PROF. A. SUCIU

MTH 1230 - LINEAR ALGEBRA - FALL 1997

Answers to Quiz 4

Problem 1

Let

A={{0,0},{1,0},{1,1}};  b={{5},{1},{2}};

(a)	Find the least squares solution of the inconsistent system A.x = b.

x=Inverse[Transpose[A].A].Transpose[A].b

or, more simply:

x=PseudoInverse[A].b

(b)	Use your answer in part (a) to find the projection of b onto the column space of A.

A.x

Problem 2

A company gathers the following data:

Year:						1993	1994	1995	1996	1997
Annual Sales (in millions of dollars):      	0.8	2	3	4.2	5

Represent the years 1993, ... ,1997 as -2,-1,0,1,2, respectively, and let  x denote the year.  
Let y denote the annual sales (in millions of dollars).

(a)	Find the least squares line relating x and y.

A={{-2,1},{-1,1},{0,1},{1,1},{2,1}}; yy={{0.8},{2},{3},{4.2},{5}};

{{m},{b}}=Inverse[Transpose[A].A].Transpose[A].yy

y[x_]=m*x+b

or, more simply:

y[x_] = 
      Fit[{{-2, 0.8}, {-1, 2}, {0, 3}, {1, 4.2}, {2, 5}}, {1, x}, x]

(b)	Use the equation obtained in part (a) to estimate the annual sales for the year 1999.

y[4]

Problem 3

Apply the Gram-Schmidt process to the vectors

a[1]={{1,-1}}; a[2]={{2,3}};

and write the result in the form A=Q.R.

A = Transpose[Join[a[1], a[2]]]

\(qr = QRDecomposition[A]; 
Q = Transpose[qr[\([1]\)]]; \ \ 
    R = qr[\([2]\)]; \)

TableForm[Q]

TableForm[R]

A == Q.R

Problem 4

Let

A={{1,1},{-2,4}}

(a)	Find the characteristic polynomial of A.

cp[A]=Det[A-λ*IdentityMatrix[2]]

(b)	Find the eigenvalues of A.

Solve[cp[A]==0,λ]

{λ[1],λ[2]}={λ/.%[[1]],λ/.%[[2]]}

or, more simply:

{λ[1],λ[2]}=Eigenvalues[A]

(c)	Find a basis for each eigenspace of A.

x[1]=NullSpace[A-λ[1]*IdentityMatrix[2]][[1]]

x[2]=NullSpace[A-λ[2]*IdentityMatrix[2]][[1]]

or, more simply:

{x[1],x[2]}=Eigenvectors[A]

(d)	Find a diagonal matrix Λ and an invertible matrix S such that A=S.Λ.(S^(-1))

Λ=DiagonalMatrix[{λ[1],λ[2]}]

S={x[1],x[2]}

Check:

A==S.Λ.Inverse[S]

Problem 5

Let A be a 3 by 3 matrix, with eigenvalues

λ[1]=-2; λ[2]=0; λ[3]=5;

(a)	Compute tr(A) and det(A).

tr[A]=Apply[Plus,Table[λ[i],{i,3}]]

det[A]=Apply[Times,Table[λ[i],{i,3}]]

(b)	Is A invertible?  Explain your answer.

No, since det[A]=0.

(c)	Is A diagonalizable?   Explain your answer.

Yes, since the eigenvalues are all distinct.

(d)	Compute tr(A^3) and det(A^3).

tr[A^3]=Apply[Plus,Table[λ[i]^3,{i,3}]]

det[A^3]=Apply[Times,Table[λ[i]^3,{i,3}]]