Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
0

Matrix projection blues

asked 5 years ago

ortollj gravatar image

updated 5 years ago

Hi on OpenCourseware MIT site: Lecture 15: Projections onto subspaces

[edited :the code on sagecell sagemath org was not the good one ! it was the first version I wrote. when I updated the code in the cell, that does not work, I had to open a new cell]

code on sagecell sagemath org

Q1:
p is the b projected vector on vector a 
below all letters are matrices
E=B-P with P=X*A  
E=B-X*A as E perpendicular to A => dot product(A,E)) = 0 means A.transpose()*E=0
then A^T*(B-X*A)=0 so A^T*(X*A)=A^T*B (and this is false !)
but Gilbert Strang write X*A^T*A=A^T*B (and this is good !)
but we are not allowed to commute A^T*X*A by X*A^T*A if X is a matrix !
I know I made a mistake in my raisonning but I fail to find it !

Q2 : Why I must write  X=A * (A.transpose())/(( (A.transpose()) * A ).det())  
instead of             X=A * (A.transpose())/(( (A.transpose()) * A ))
why I need to add .det() ?
Preview: (hide)

Comments

I know the first question is basic math question not a sagemath question, sorry, tell me if I must post it on a math forum instead. now the code in the link is my last code.

ortollj gravatar imageortollj ( 5 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 5 years ago

Juanjo gravatar image

updated 5 years ago

Q1. In his lecture, Prof. Strang begins with the simplest case: the orthogonal projection of a vector b onto a one dimensional subspace S=spana, a being a non-null vector in Rn. The projection vector p should be a multiple of a, so Prof. Strang writes it as p=xa. Here x is a scalar number, not a matrix, and a is a vector, identified with a n×1 matrix. He wants to deduce that p=Pb, where P is the projection matrix P=1aTaaaT,

which is an n×n matrix. To this end, Prof. Strang writes the projection vector as p=ax. Now, you should see p and a as n×1 matrices and x as a one dimensional vector or a 1×1 matrix, so that a and x can be multiplied. Thus, we have xa=ax.
This identity does not mean that a and x are two matrices that commute. Just read the left and right sides as stated above. It is true that the notation may be a bit misleading. Perhaps it would be better to write (x) instead of x if x should be seen as a 1×1 matrix (parentheses are used to delimit matrices). For example, 4(123)=(4812)=(123)(4).

The advantage of expressing p as ax is that generalization is then possible. If S is spanned by the linearly independent vectors a1,,ak, the orthogonal projection p of a vector b onto S should be a linear combination of a1,,ak, that is, p=x1a1++xkak=AX

with A=(a1||ak)
and X=(x1xk)
The reasoning in Prof. Strang’s lecture would then show that p=Pb, where P is now the projection matrix P=A(ATA)1AT.

Returning to your question, you write P=X*A where, in fact, you should write p=xa and consider x being an scalar, not a matrix. Consequently, since x is a scalar, from aT(bp)=0, one has aTb=aTp=aT(xa)=xaTa.

Hence x=aTbaTa.

Q2. In your code, A.transpose()*A is a 1×1 matrix. You cannot divide by a matrix. Thus you need to extract the unique element of this matrix, either with the .det() method or simply writing (A.transpose()*A)[0,0]. By the way, note that, in the video, the projection matrix is denoted by P, not X.

In SageMath, I think that it is better to use vector instead of matrix to represent a, b and p, as shown here.

Preview: (hide)
link

Comments

Thanks a lot, Juanjo I understand my mistakes now. I'm a bit ashamed of the confusion I made, sorry.

ortollj gravatar imageortollj ( 5 years ago )
1

Don't worry. Glad to help you

Juanjo gravatar imageJuanjo ( 5 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 1,254 times

Last updated: Jun 04 '19