HP-49G Vector-Matirx Multiplication



#9

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.


#10

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.

#11

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


#12

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

#13

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


#14

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] <sto> A (1 row x 3 columns)

[[1 2 3]
[1 2 3]
[1 2 3]] <sto> 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


#15

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



#16

[ 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 4,129 12-02-2013, 01:18 PM
Last Post: Alberto Candel
  HP Prime - vector question bluesun08 3 1,841 11-18-2013, 07:26 PM
Last Post: Han
  HP Prime - Imlicit multiplication bluesun08 3 1,596 11-12-2013, 10:57 AM
Last Post: Han
  [HP-Prime CAS] Vector Calculus Library CompSystems 7 2,885 10-31-2013, 12:48 PM
Last Post: Han
  HP-Prime/Xcas: vector/list indexing fhub 6 2,965 10-27-2013, 04:52 PM
Last Post: fhub
  HP Prime : inconsistency with implicit multiplication in CAS Olivier Lecluse 6 2,410 10-27-2013, 03:30 AM
Last Post: parisse
  HP Prime: Vector field CURL(). How-to... Chris Tvergard 4 1,706 09-26-2013, 03:55 PM
Last Post: Chris Tvergard
  WP-34S: Program for vector (3D) manipulation Marcel Samek 4 1,887 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 1,245 08-22-2013, 03:30 PM
Last Post: Joe Horn
  Why does PEMDAS do multiplication and division before addition and subtraction? Don Shepherd 12 3,546 07-31-2013, 10:59 AM
Last Post: robert rozee

Forum Jump: