HP-49G Vector-Matirx Multiplication « Next Oldest | Next Newest »

 ▼ William Junior Member Posts: 12 Threads: 3 Joined: Jan 1970 02-08-2006, 10:25 AM Can someone please tell me why my HP-49G will not multiply a vector [nx1] times a matrix [nxn], but it will multiply a matrix [nxn] times a vector [nx1]? Vector-matrix multiplication is a perfectly valid mathematical operation, but the HP-49G gives me an "Invalid Dimension" error. I know that I can overcome this error by placing the vector in the last row of an [nxn] matrix, but I perform this operation many times for my some of my engineering courses and this process becomes cumbersome, especially during an exam. ▼ Marcus von Cube, Germany Posting Freak Posts: 3,283 Threads: 104 Joined: Jul 2005 02-08-2006, 10:38 AM William, you need a "horizontal" vector on the left side of a matrix. To create it, just enclose a vector in another pair of brackets. ```2:[ [ 1 2 3 ] ] 1:[ [ 1 0 0 ] [ 0 1 0 ] [ 0 0 1 ] ] ``` This multiplies fine. Marcus Edited: 8 Feb 2006, 11:01 a.m. Namir Posting Freak Posts: 2,247 Threads: 200 Joined: Jun 2005 02-08-2006, 02:46 PM When you multiple a vector and a matrix you are really multiplying a row/column matrix with a matrix. Therefore the rule regarding the matrices' dimensions must be obayed. Namir ▼ Chris Dean Member Posts: 120 Threads: 9 Joined: Aug 2005 02-08-2006, 03:54 PM ```You can only multiply matrices A and B if the number columns of A is the same as the number of rows of B. Consider C=AxB then if A is MxN and B is NxP then resultant matrix C is MxP. Cij=sum(Aik*Bkj) where k = 1 to N ``` Karl Schneider Posting Freak Posts: 1,792 Threads: 62 Joined: Jan 2005 02-08-2006, 09:51 PM William -- As others explained previously, the result of matrix multiplication A*B includes the set of all dot products of the rows of A with the columns of B. The matrices must be dimensioned accoringly: the number of columns of A must equal the number of rows of B. A column vector is a matrix with only one column; a row vector is a matrix with only one row. Also: In general, matrix multiplication is not commutative, even if both orders of multiplication are defined under the rules. If one wants to left-multiply a column vector by a matrix, the column vector must usually be transposed as a row vector. The result will be dimensioned as a row vector. There is a built-in function ATB on the HP-15C for that purpose. In Matlab, it would be A'*B. A useful theorem: (A*B)T = BT*AT Regards, -- KS ▼ William Junior Member Posts: 12 Threads: 3 Joined: Jan 1970 02-09-2006, 02:27 PM Thank you all for your input. I may not have made my problem clear in my previous message. So, I will try again. This is what I am doing. [1 2 3] A (1 row x 3 columns) [[1 2 3] [1 2 3] [1 2 3]] B (3 rows x 3 columns) The number of columns in A i equal to the number of rows in B. I am defining these matrices via MTRW. The operation AxB should yield...[6 12 18]...however, my HP-49G says..."Invalid Dimension". The calculator will calculate BxA = [14 14 14]; THIS operation should give me an error message. Isn't this the opposite of what I should be getting? Do I have some obscure flag un-checked? Thank you, William ▼ Karl Schneider Posting Freak Posts: 1,792 Threads: 62 Joined: Jan 2005 02-10-2006, 01:05 AM William -- You're in luck -- I also happen to have an HP-49G, so was able to try your example. (I should point out that in RPL, it's {data} 'A' STO, not {data} STO 'A'...) I follow the example -- it looks to me like a row-vector A and a square matrix B. The vector entered with a single set of brackets on one line even looks like a row vector in the Matrix Editor. But, when multiplying them with 'A' above 'B' in the stack, I get the same dimension error. Marcus von Cube's post has the fix: Make 'A' a true row vector by enclosing it within an extra set of brackets. ("TRAN" will also transpose a matrix or vector on the 49G.) I noticed that, for whatever reason, the transpose made no difference in the vector's layout in Matrix Editor. [14 14 14]T is the product B*AT -- i.e., the matrix times the column vector. I struggled to get my 48G to do what I wanted in this example, also. How counterintuitive! This deepens my appreciation for the HP-15C and HP-42S, both of which I would trust far more than any RPL model to use on an important exam. -- KS ▼ Marcus von Cube, Germany Posting Freak Posts: 3,283 Threads: 104 Joined: Jul 2005 02-10-2006, 03:17 AM ```[ 1 2 3 ] ``` is a column vector, while ```[[ 1 2 3 ]] ``` is a row vector. The strange thing is that matrix editor doesn't seem to know the difference. Or does he? Function key F2 toggles the vector mode. I checked it on the 48S, 48G and 49G+, all three have this toggle. The 49G+ uses a single boldface pair of brackets in stack display to denote a row vector while the older calculators keep the double pair of brackets. I assume the RPL designers on the 28C/S wanted the more common vector type (column vector) to have the simpler notation. The matrix editor came into play much later. Marcus

 Possibly Related Threads... Thread Author Replies Views Last Post HP Prime: adding an entry to a vector Alberto Candel 12 1,972 12-02-2013, 01:18 PM Last Post: Alberto Candel HP Prime - vector question bluesun08 3 788 11-18-2013, 07:26 PM Last Post: Han HP Prime - Imlicit multiplication bluesun08 3 727 11-12-2013, 10:57 AM Last Post: Han [HP-Prime CAS] Vector Calculus Library CompSystems 7 1,382 10-31-2013, 12:48 PM Last Post: Han HP-Prime/Xcas: vector/list indexing fhub 6 1,220 10-27-2013, 04:52 PM Last Post: fhub HP Prime : inconsistency with implicit multiplication in CAS Olivier Lecluse 6 1,123 10-27-2013, 03:30 AM Last Post: parisse HP Prime: Vector field CURL(). How-to... Chris Tvergard 4 809 09-26-2013, 03:55 PM Last Post: Chris Tvergard WP-34S: Program for vector (3D) manipulation Marcel Samek 4 867 09-05-2013, 05:29 AM Last Post: Marcus von Cube, Germany [HP-Prime CAS] list[x,y,z], vector[x, y, z ] ... data type operation? CompSystems 1 623 08-22-2013, 03:30 PM Last Post: Joe Horn Why does PEMDAS do multiplication and division before addition and subtraction? Don Shepherd 12 1,669 07-31-2013, 10:59 AM Last Post: robert rozee

Forum Jump: