Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > Other Topics > Science, Math, and Philosophy
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-09-2007, 03:26 PM
CallMeIshmael CallMeIshmael is offline
Senior Member
 
Join Date: Dec 2004
Location: Tis the season, imo
Posts: 7,849
Default Matrix help needed

Im pretty rusty when it comes to matrices, and I was wondering if someone could help me with the following problem... I need it for some code Im writing


given that

A*B = C

where, A, B and C are all matrices of dimensions in the form:

A: (m X n)
B: (n X 1)
C: (m X 1) (with m, n > 1)

is there a QUICK method of determining B, given A and C?


Also, it might be important to note that the sum of each of the columns of A is 1, which also means that sum(B) == sum(C).


So, take, for example:

[0.8 0.6 0.4] X [0.4]..=..[0.48]
[0.2 0.4 0.6] .. [0.2]......[0.22]
.....................[0.1]


Is there a quick way to go from (0.48; 0.22), to (0.4, 0.2, 0.1), given that you also know the first matrix


Im not really sure how to define 'quick', but assume that what I want to do means that the above operation is carried out thousands of times. Bascially, I dont want to have to row reduce / solve the equation each time.

thanks

EDIT: m != n
Reply With Quote
  #2  
Old 06-09-2007, 09:48 PM
danny danny is offline
Junior Member
 
Join Date: Oct 2003
Posts: 9
Default Re: Matrix help needed

In general, if n > m as in your example, the problem is underdetermined. You have m equations and n unknowns. In your example, the vector (0.3, 0.4, 0) is also a solution.

On the other hand, if n < m the problem is overdetermined. It may not have a solution. In either case, you must have some criteria for choosing the "best" solution. The methods for solving problems of this type are somewhat complex. Try looking up singular value decomposition.
Reply With Quote
  #3  
Old 06-10-2007, 12:03 AM
m_the0ry m_the0ry is offline
Senior Member
 
Join Date: Aug 2006
Posts: 790
Default Re: Matrix help needed

Row reduction is the only way to do this kind of operation. I recommend using a TI89 because you can enter the matrix in standard form:

[A|C]

and just tell it to perform row reduction.
Reply With Quote
  #4  
Old 06-10-2007, 12:47 AM
Fly Fly is offline
Senior Member
 
Join Date: Jan 2006
Location: placing balls into cells
Posts: 2,075
Default Re: Matrix help needed

if A*B = C, then

A^-1 * A * B = A^-1 * C

so

B = A^-1 * C
Reply With Quote
  #5  
Old 06-10-2007, 01:34 AM
m_the0ry m_the0ry is offline
Senior Member
 
Join Date: Aug 2006
Posts: 790
Default Re: Matrix help needed

inverting a matrix is certainly not any easier than row reduction.
Reply With Quote
  #6  
Old 06-10-2007, 01:51 AM
CallMeIshmael CallMeIshmael is offline
Senior Member
 
Join Date: Dec 2004
Location: Tis the season, imo
Posts: 7,849
Default Re: Matrix help needed

is it even possible to invert a non square matrix?

I didnt think it was.. but, like I said, Im not that knowledgeable of matrices


(also... yeah, it does seem like the only way is to RR it)
Reply With Quote
  #7  
Old 06-10-2007, 02:25 AM
DiceyPlay DiceyPlay is offline
Senior Member
 
Join Date: Jul 2004
Posts: 302
Default Re: Matrix help needed

I like Danny's response on this one.

In general non-square matrices do not have inverses.
Reply With Quote
  #8  
Old 06-10-2007, 03:29 AM
m_the0ry m_the0ry is offline
Senior Member
 
Join Date: Aug 2006
Posts: 790
Default Re: Matrix help needed

sorry I neglected to notice your edit. The fact the matrix is nonsquare makes a great deal of difference, and the answer to your question now mostly depends on how this is being applied.

When m>n there will be a single solution (null being possible), when n>m there will be infinite solutions. For most real applications in the former case (m>n) a row reduction will find B. There is no easy way to row reduce without using a computational device.
Reply With Quote
  #9  
Old 06-10-2007, 05:01 AM
Neuge Neuge is offline
Senior Member
 
Join Date: Jul 2004
Posts: 784
Default Re: Matrix help needed

[ QUOTE ]
is it even possible to invert a non square matrix?

I didnt think it was.. but, like I said, Im not that knowledgeable of matrices


(also... yeah, it does seem like the only way is to RR it)

[/ QUOTE ]
http://en.wikipedia.org/wiki/Pseudoinverse

This problem is generally not solvable when n>m. If m>n, and A has full column rank, you can use a least-squares method where norm(C-AB) is minimized. For a well-conditioned A you can probably just solve the normal equation, but most likely you'll need to use a QR or SVD decomposition. It's pretty easy to automate with python.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.