-1

I am trying to understand the formula

c=A(i:j,:)*inv(A)*b

where i,j=1:length(A). Assume that A is invertible

The above formula allow us copy all element from index i to index j in vector b. I also implemented it by matlab code as follow code. However, I don't clearly understand why the above formula allow we copy elements in vector b. Let see my formula and my implementation, please explain help me? Thank you so much When I implement in matlab the code is

A =[ 10     1     7    10     9;
     3     9     3     1     2;
     9     2     3     5     4;
     1     2     8     6     1;
     5     2     6     6    10]

b =[ 8;
     5;
     8;
    10;
     6]

Then c=A(3:5,:)*inv(A)*b=[8;10;6] The result looks like c=b(3:5,:);

More extention: Assume D is matrix 4 by 5 in which 1st to 3rd row are created from 3rd row to 5th row of A. The last row of D is ones. Then the above formula is

c(1:4,:)=D*inv(A)*b=[8;10;6;1.12]...

It also copy the 3rd to 5th elements of vector b

John
  • 2,838
  • 7
  • 36
  • 65

1 Answers1

4

For invertible matrices A the code c = A(i:j,:)*inv(A)*b is (up to numerical error) equivalent to:

tmp = A*inv(A)*b;
c = tmp(i:j);

The matrix product A*inv(A) will cancel each other out (as does 123*(1/123) or more generally x*(1/x) for x~=0), (again: for invertible matrices up to numerical error), so it is equivalent to:

tmp = b;
c = tmp(i:j);

There is really no reason to do any of the above, you will only introduce numerical error and it won't even work correctly for singular matrices! Simply use c = b(i:j) instead.

knedlsepp
  • 6,065
  • 3
  • 20
  • 41
  • Do you tried to implement the D=ones(4,5); D(1:3,:)=A(3:5,:); then c=D*inv(A)*b=???. It will be copy the element from 3 to 5 and generate a new element at last. Assume that A is invertible. – John Apr 13 '15 at 16:46
  • @user8264: It is not a wrong explanation. It is the wrong question! – knedlsepp Apr 13 '15 at 17:58
  • Sorry about my question. Maybe I did not clearly understand. However. I get it from very good paper and standard. For short paper, let see it in here http://on-demand.gputechconf.com/gtc/2012/posters/P0473_Implementation_gpu_raptor_code.pdf – John Apr 14 '15 at 01:38
  • @user8264: I'm quite certain you misread the paper. In the pdf you provided I can't find such a formula. – knedlsepp Apr 14 '15 at 08:12
  • Actualy, I am working in that area. I know that we are not expert in that area. Hence, I just give a simple equation. The paper used G_LT matrix instead of D matrix in my case. The A matrix is a matrix that contains GLT matrix. The name of output code is systematic code. Hence the formula (2) and (3) that you need – John Apr 14 '15 at 08:17
  • @user8264: There is no formula (2) and (3) in the link. The second and third formulas don't contain what you are asking for. – knedlsepp Apr 14 '15 at 08:29
  • Sorry. The paper is not numering it. However, more clearly, you can see at formula (1)- same author the paper https://www.dropbox.com/s/jvus7h4q8lja5h4/06026424.pdf?dl=0 – John Apr 14 '15 at 08:31
  • @user8264: Well the paper talks about: `G_LT*inv(A)*d` which is entirely different from `A*inv(A)*d`. – knedlsepp Apr 14 '15 at 08:46
  • Yes, right. Note that G_LT is one part of A. G_LT looks like D matrix or A(3:5,:) in my example. – John Apr 14 '15 at 08:48
  • @user8264: I can't tell you more than that `A(i:j,:)*inv(A)*b` is a useless operation, which is what you were asking for. – knedlsepp Apr 14 '15 at 08:51
  • Yes. I am trying to understand why it can copy elements from matrix b to c by the above formula. Your explaination is one simple case... For general case, it shown in the formual (1) in the above paper – John Apr 14 '15 at 08:53
  • 2
    @user8264: Well, even if you disagree I think I answered the question you asked. Good luck. – knedlsepp Apr 14 '15 at 08:55
  • Thank for your answer, I am looking for a good explaination. Do you have any comment to make my question more clearly for users – John Apr 14 '15 at 08:58
  • 1
    @user8264: Read a book about linear algebra. – knedlsepp Apr 14 '15 at 09:00