The Museum of HP Calculators

HP Forum Archive 18

 How can i solve this kind of linear systemMessage #1 Posted by Alexander DeLarge on 24 Nov 2007, 4:13 p.m. Sorry for asking this kind of noob question but i'm not advanced with my 50g. for example: X + Y + Z = 3 X + 2Y + 3Z = 6 I did it with the NUM.SLV and the result was [1,1,1] which is correct but well I would like to get a result like [t,3-2t,t], is this possible to get it solved this was on my 50g? thanks.

 Re: How can i solve this kind of linear systemMessage #2 Posted by Allen on 24 Nov 2007, 6:40 p.m.,in response to message #1 by Alexander DeLarge Greetings, I assume you mean: ```X + Y + Z = 3 X + 2Y + 3Z = 6 ``` and not ``` X + Y + Z = 6 3 X + 2Y + 3Z = 6 ``` In either case there are only two equations and three unknowns. Is there another that is not included here? It would certainly be an impressive marketing point for HP if the 50g could completely solve the above equation, given only two equations.

 Re: How can i solve this kind of linear systemMessage #3 Posted by Stefan Vorkoetter on 24 Nov 2007, 9:52 p.m.,in response to message #2 by Allen I think he's looking for a parametric solution, whereas the 50g is just finding one of the infinitely many possible solutions. Stefan

 Re: How can i solve this kind of linear systemMessage #4 Posted by Alexander DeLarge on 24 Nov 2007, 8:18 p.m.,in response to message #2 by Allen Thanks Allen. Of course it has to be ```X + Y + Z = 3 X + 2Y + 3Z = 6 ``` Well of course it couldn't be solved numerically but at least i would expect the result to be [t,3-2t,t] not [1,1,1] as given by the calculator.

 Re: How can I solve this kind of linear systemMessage #5 Posted by Rodger Rosenbaum on 25 Nov 2007, 11:10 a.m.,in response to message #4 by Alexander DeLarge Compute the solution as I described in another post. Then set the calculator to exact mode and do: SWAP OVER - XQ SWAP XQ 't' * + and you will see what you want, except for the strange thing the calculator does with symbolic arithmetic sometimes. You'll see: ```[ t 3+-2*t t ] ``` If you do a swap before the last +, you'll get: ```[ t -2*t+3 t ] ``` which you may like better.

 Underdetermined linear systems on the HP-50G?Message #6 Posted by Karl Schneider on 25 Nov 2007, 4:04 a.m.,in response to message #1 by Alexander DeLarge ``` X + Y + Z = 3 X + 2Y + 3Z = 6 ``` As indicated, a parameteric solution would be (x(t), y(t), z(t)) = (t, 3-2t, t) This is an underdetermined system. From the HP-49G User's Guide, page 6-7: Quote: Usually there is an infinite number of solutions to these systems. The HP-49G returns the solution with the minimum Euclidean norm. Unless enhanced functionality for linear systems was developed for the HP-50G, I'd assume that the answer of (1, 1, 1) meets the same specification. What does the manual state? -- KS

 Re: How can I solve this kind of linear systemMessage #7 Posted by Rodger Rosenbaum on 25 Nov 2007, 10:51 a.m.,in response to message #1 by Alexander DeLarge This is an interesting problem. The solution to your problem can be written: [ 0 3 0 ] + t*[ 1 -2 1 ] or: [ 1 1 1 ] + t*[ 1 -2 1 ] That is, a particular solution vector plus some multiple of another vector. That second vector is in the null space of the coefficient matrix, meaning that the coefficient matrix times [ 1 -2 1 ] gives [ 0 0 ]. And, therefore, the coefficient matrix times any multiple of [ 1 -2 1 ] also gives [ 0 0 ]. So any multiple of [ 1 -2 1 ] can be added to a solution vector and the result is still a solution vector. It just so happens, mirabile dictu, that the HP48G and descendants can give the solution you want. All you need to do is to find a vector in the null space of the coefficient matrix. You do this by placing the coefficient matrix on the stack and executing SVD. Three items will be returned to the stack. The second item, the V matrix, has a unit length vector in the null space as its last row. The elements of that vector aren't integers, but in this case they can be made integers by dividing the vector by its first element. Keep in mind that it's only because this system is underdetermined that it's guaranteed to have a non-empty null space. If it were fully determined it might not have a non-empty null space. Here's a little program (not necessarily optimized) that can do the entire job. Just put the coefficient matrix on level 2 of the stack and the column matrix on level 1 and execute PARAM. ```----------------- PARAM << OVER LSQ TRN ->ROW DROP SWAP DUP SIZE 2 GET SWAP SVD ROT DROP2 SWAP ROW- SWAP DROP DUP 1 COL- SWAP DROP / >> ------------------ ``` Just do: ```2: [[ 1 1 1 ] [ 1 2 3 ]] 1: [[ 3 ] [ 6 ]] PARAM ``` and see: ```2: [ 1. 1. 1. ] 1: [ 1. -2. 1. ] ``` On level 2 is a (smallest Euclidean norm) solution vector, and on level 1 is a vector in the null space of the coefficient matrix. Press - and see [ 0. 3. 0. ], the solution vector you posted. This vector plus any multiple of the vector that was on level 1 is another solution. When you still have: ```2: [ 1. 1. 1. ] 1: [ 1. -2. 1. ] ``` on the stack, press 7 * + and see [ 8. -13. 8 ], another solution, and so forth. It may not always be possible to convert the last row of the V matrix (from the SVD) to a vector of integers, but even if not, it still provides the parameterized solution you want. Try: ```2: [[ 1 1 1 ] [ 7 3 5 ]] 1: [[ 3 ] [ 6 ]] PARAM ``` and see: ```2: [ -1.25 3.25 1. ] 1: [ 1. 1. -2. ] ``` In this case, the null space vector did convert to a vector of integers. You could enlarge the program to test if all the elements of the vector can be made integers, and if not, just keep the last row of the V matrix as it was. Edited: 25 Nov 2007, 10:54 a.m.

Go back to the main exhibit hall