Quick help needed on a Matrix Multiplication

In summary: I just need to multiply A with another matrix and I should be able to get back my original matrix.In summary, Yondaime5685 is trying to figure out how to multiply two matrices, but is having difficulty because he does not remember the steps. He asks for help on a forum, and chogg provides a solution.
  • #1
Yondaime5685
27
0
I have a small problem where I remember I learned it in the past. But now I can't seem to recall how to do it. I searched on google, but I think even though it is probably really easy, I may not have worded it right to get the references I want. So I decided to ask here.

Here is the problem:

Lets say I have this 4x3 matrix: [1,2,3;5,6,7;9,0,1;3,4,5]

What matrix can I multiply this with or by to get back, for this example, 1&2 in the first row and 6&7 in the second row and the rest should be zero...?

Now what is that general structure I need to make the second matrix to get back or be able to "pick off" any value from the first matrix that I choose..?

I know this is an easy question but I don't have my Math Physics book with me and I'm terrible at wording what I need to ask. Haha.

Thanks in advance.
 
Physics news on Phys.org
  • #2
Hi Yondaime5685! :smile:

Let Ei be the 4x4 matrix with a 1 on place (i,i) and a zero elsewhere. Let Ei' be the 3x3 matrix with a 1 on place (i,i) and a zero elsewhere. Let A be your matrix.

To obtain a matrix which "picks off" the value (i,j) of A, you just do

[tex]E_iAE_j^\prime[/tex]

For example

[tex]\left(\begin{array}{cccc} 0 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0\\ \end{array}\right)
\left(\begin{array}{ccc} 1 & 2 & 3\\ 5 & 6 & 7\\ 9 & 0 & 1\\ 3 & 4 & 5\\ \end{array}\right)
\left(\begin{array}{cccc} 0 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & 1\\ \end{array}\right)
=
\left(\begin{array}{cccc} 0 & 0 & 0\\ 0 & 0 & 7\\ 0 & 0 & 0\\ 0 & 0 & 0\\ \end{array}\right)[/tex]

Can you such a reasoning to solve your problem?
 
Last edited:
  • #3
I don't think there is a solution to do what you want. Let me explain why I think so.

First, I'll try to state your goal. You are trying to take an [itex]m \times n[/itex] matrix ("[itex]A[/itex]"), multiply it with other matrices, and get back another [itex]m \times n[/itex] matrix ("[itex]B[/itex]"). The most general way to do that is to hit it from both sides. So you're looking for an equation of the form
[tex]
B = MAN
[/tex]
where [itex]M[/itex] is an [itex]m \times m[/itex] matrix, and [itex]N[/itex] is an [itex]n \times n[/itex] matrix. Your goal: the entries of [itex]B[/itex] should be either the same as the corresponding entries in [itex]A[/itex], or zero... and this should hold for any values of [itex]A[/itex].

Does that sound right?

Now, consider an element that you want to set to zero. Say, [itex]B_{ij}=0 \forall A[/itex]. Well, we have
[tex]B_{ij} = \sum_k \sum_l M_{ik} A_{kl} N_{lj} = \sum_k\sum_l (M_{ik}N_{lj}) A_{kl}[/tex]
In other words: some particular linear combination of the entries of [itex]A[/itex] adds up to zero. Does it hold for other values of [itex]A[/itex]? Plainly not: if we change element [itex]A_{kl}[/itex] by [itex]\delta[/itex], then that "zero" element [itex]B_{ij} = \delta M_{ik}N_{lj} \ne 0[/itex].

So, it seems to me you can't mask out components of matrices by matrix multiplication.
 
  • #4
Silly me! Of course you can make it work by setting, for instance, [itex]M_{ik} = 0[/itex] for all k. This will mask out the entire i'th row of B.

Alternatively, setting [itex]N_{lj}=0[/itex] for all l masks out the j'th column of B.

So it seems you can mask off parts of a matrix, but you have to do a whole row or whole column at a time.

If you want to pick out an individual matrix element -- say, element (i,j) -- setup M so that its i'th diagonal element is 1 (and all the rest are zero), and N so that its j'th diagonal element is 1 (and all the rest are zero).

I should refrain from posting except after a good night's sleep. :P :)
 
  • #5
-micromass

Yes, that seems to work. But really what I need is what chogg stated. I need to able to "mask out", as chogg perfectly put it, more than one element. Will that work for picking out more than one element..? Thanks for the help.

-chogg
Yes, that is exactly what I need to do. You see I'm going to have one matrix([A]) the size of 680x480 which will have certain elements that are essentially non-zero and the rest will be zero. So basically, everywhere the elements are zero in [A], I need to change the values in another matrix , which has the same dimensions, to zero as well.

In the end, the third matrix [C] should have all the zeros from [A] but where it was non-zero in [A] to have whatever values from .

Maybe I remember it wrong and it isn't thorough matrix multiplication. Is there any matrix operations I can use to achieve my goal..?

-edit

I didn't see your last post chogg...
 
  • #6
Okay, after experimenting with your post, micromass, I found out it does work for any value you want to pick off. So I want to thank you for that. But I have to translate this into coding and it seems like it is going to be more code to write this than just my original idea to use an if and else to read off every element from one matrix and use it to pick off from the second matrix.

I just thought there was a simple matrix operation to get the same result. But, thanks to both micromass and chogg for helping me out. :smile:
 
  • #7
Ah, so it's a programming question. That makes it easy. :) Just define a mask -- a matrix of the same size as A with ones where you want to keep the elements and zeroes elsewhere. Then, instead of matrix multiplication, just do element-by-element multiplication.

I don't know what language you're using, but element-by-element multiplication is always easy to do. I usually use R, and it's the default multiplication of two matrices. :)
 
  • #8
-chogg

Yes. That helps. I'm using Matlab and remember seeing a code in the User's Guide that probably does the same thing. Thanks. :tongue2:
 

1. What is matrix multiplication?

Matrix multiplication is a mathematical operation in which two matrices are multiplied together to create a new matrix. It involves multiplying corresponding elements of the matrices and then summing the products to obtain the elements of the new matrix.

2. How do I perform matrix multiplication?

To perform matrix multiplication, you need to make sure that the number of columns in the first matrix is equal to the number of rows in the second matrix. Then, multiply corresponding elements of the matrices and add them together to obtain the elements of the new matrix.

3. What are the properties of matrix multiplication?

Matrix multiplication has the following properties: associative (A(BC) = (AB)C), distributive (A(B+C) = AB + AC), and not commutative (AB ≠ BA). Additionally, the identity matrix (I) acts as the identity element for matrix multiplication.

4. Why is matrix multiplication important?

Matrix multiplication is important in various fields such as physics, engineering, and computer science. It is used to represent linear transformations, solve systems of linear equations, and perform calculations in computer graphics and machine learning.

5. Can matrix multiplication be applied to matrices of any size?

No, matrix multiplication can only be performed on matrices that have compatible dimensions. This means that the number of columns in the first matrix must be equal to the number of rows in the second matrix. Otherwise, the operation is not defined.

Similar threads

  • Linear and Abstract Algebra
Replies
3
Views
970
  • Linear and Abstract Algebra
Replies
7
Views
414
  • Linear and Abstract Algebra
Replies
12
Views
1K
Replies
34
Views
2K
Replies
4
Views
2K
  • Linear and Abstract Algebra
Replies
6
Views
1K
  • Linear and Abstract Algebra
Replies
15
Views
4K
  • Precalculus Mathematics Homework Help
Replies
25
Views
886
  • Linear and Abstract Algebra
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
1K
Back
Top