
×InformationFix Windows 10 Update Issues
Resolve Windows 10 related issues for your HP computers or printers by HP Windows 10 Support Center

×InformationFix Windows 10 Update Issues
Resolve Windows 10 related issues for your HP computers or printers by HP Windows 10 Support Center
 HP Community
 >
 Other Products
 >
 Calculators
 >
 Matrix summation
 Mark Topic as New
 Mark Topic as Read
 Float this Topic for Current User
 Bookmark
 Subscribe
 Mute
 Printer Friendly Page
Create an account on the HP Community to personalize your profile and ask a question
Solved!
Matrix summation
02222017 07:43 PM
Hi I want to debugg the following program to solve the summation of matrix mulplied by a factor as shown in the picture
I stored the matrix in the variable A, t stored with the value 25 and p stored with the value 0.19
Next I run this programs
« A SIZE 1 GET 'R' STO » and then run the prog
« A 1 R START p t 20  ^ * + 1 'S' STO NEXT S "S" >TAG »
I recieved a bad argument type error after getting the partial result which is ok as shown below
After using the following program << AXL ZLIST ZLIST >> "Z STANDS FOR SIGMA" , I got the final result of 0.007428297 which is also ok, but I am unable to fix the error. Any help to debug this prog or other suggestion would be very much appreciated.
Reynel
Solved! Go to Solution.
02222017 10:47 PM
I would suggest singlestepping your program and watching what happens on the stack. You'll see that the first problem occurs when the multiplication (*) is executed for the first time. You are intending to multiply only the first element by p^(t20), but you're multiplying the entire matrix by it. Then the addition (+) is executed with only the matrix on the stack, thus giving a "Too few arguments" error. You say that you get a "Bad argument type" error, which either means that you started with something on the stack (what?) or your actual program is different from your posted listing.
There are of course many ways to "fix" your program, but IMHO the best way to get the answer you seek is to eliminate the START / NEXT loop. Just multiply the whole matrix by the constant, then sum up the elements using either CNRM (if you know ahead of time that all the elements will be positive) or your solution of AXL SigmaLIST SigmaLIST.
If that doesn't answer your question, please advise. Disclaimer: I don't work for HP; I'm just another happy HP calculator user.
02232017 09:13 AM
Hi John,
Nice to hear from you again. You are always there for the rescue :). My intention is to multiply each element of a constant matrix by a the factor p^(t20) with p and t as variables. The multiplication has to cycle to every element of the matrix and finally, all the elements of the new matrix has to be summed up. I got rid off the START NEXT LOOP and went through a single step by step operation with all the elements on the stack. Finally, I assembled all these steps in a single program where I only had to change the value of t and p and the program worked well as intended. Thank you!
In one of the previous threads you wrote a litlte program to do operation with two matrices/vectors. That method did not work for the element by element addition of the 2 vectors with different dimentions for example the addition of a 4x1 matrix [ 1 , 3, 5 ,5 ] with a 3x1 matrix[10,9,20]. I can do this in other CAS, but not on HP 50g. Any ideas?
Thank you again!
02242017 03:31 AM
@REYNEL wrote:
In one of the previous threads you wrote a litlte program to do operation with two matrices/vectors. That method did not work for the element by element addition of the 2 vectors with different dimentions for example the addition of a 4x1 matrix [ 1 , 3, 5 ,5 ] with a 3x1 matrix[10,9,20]. I can do this in other CAS, but not on HP 50g. Any ideas?
[1, 3, 5, 5] + [10, 9, 20] is not defined. The HP Prime returns an answer by assuming that the second vector is [10, 9, 20, 0]. If that is what you want the HP 50g to do, then I'd write a program that finds the dimensions of both vectors, finds the larger of the two, and resizes both to that size, then adds them. Something like this:
<< DUP2 SIZE SWAP SIZE MAX ROT OVER RDM UNROT RDM + >>
Input: Any two vectors (not matrices). Output: Their sum, with undefined elements assumed to be zeros. Simplifying the program, or extending it to work with matrices, is left as an exercise for the student. 😉
02242017 06:17 AM
Regards, reynel.
Didn't find what you were looking for? Ask the community