[comp.sys.handhelds] How do I row reduce matrices on a 48?

mbharrin@sdcc13.ucsd.edu (Matt Harrington) (02/09/91)

I borrow a friends 48 for my linear algebra class.
We have not been able to find out how to put a matrix
into reduced row echelon form.  I use Matlab, where the
command is just rref(A), where A is a matrix.  The 48
comes in handy for matrix multiplication, determinants,
etc, but it would make my life infinitely more pleasurable
if it could simply row reduce a matrix.  I'm sure that
we're just not looking in the right places (in the manuals).
Should I be trying to solve multiple equations with multiple
unknowns instead?  I haven't tried this, but I did see
something posted about it earlier.  Please send any input
to me via email.

Much thanks,

--Matt

-- 
Matthew B. Harrington                        Internet: matt@ucsd.edu
University of California at San Diego        Recycle or Die.
Biophysics                                   Think! It's not illegal
                                                                yet.                       

d0mo@dtek.chalmers.se (Mats Olsson) (02/14/91)

>Actually Matt you're not missing it in the manuals.  HP did not include
>this feature in the calcualtor since I believe its only use is in solving
>multivariable linear equations.  This is much more easily accomplished
>on the HP by the following method:
...
>Then press the divide key and the answers are on the stack in the form:
-----

The method described above does only work for quadratic systems of equations.

Consider a system of equations with n unknowns and m equations.
In matrix form the system reads:

           Ax=b

where A is the coefficient matrix, type m*n, x is a vector containing
the unknowns, type m*1, and b is a vector containing the constants on
the right sides of the equations, also of type m*1.

If the solution of this system of equations is determined by
          
        x=b/A,

the matrix A have to be inversable and therefore quadratic.

<=> m=n 
<=> The system of equations is quadratic.


To solve a un-quadratic system of linear equations, one have to 
reduce the matrix into echelon form. This is easily done by my
program ->RED which I will post here very soon.. 

Be patient!!

Mats Olsson
Chalmers University of technology
Sweden

pashdown@javelin.es.com (Pete Ashdown) (02/15/91)

d0mo@dtek.chalmers.se (Mats Olsson) writes:

>To solve a un-quadratic system of linear equations, one have to 
>reduce the matrix into echelon form. This is easily done by my
>program ->RED which I will post here very soon.. 

I got this off of the mail server.  Its amazingly small and efficient in
comparison to other row-reducing programs.  It works great!

---------------------------------------------------------------------------
%%HP: T(3)A(R)F(.);
@ RWRD - Matrix Row Reduction ( matrix - reduced matrix )
@ Robert T. Wilson - University of Iowa
\<< DUP OBJ\-> OBJ\-> DROP \-> r c \<< r r 1 \-> m n s \<< 
   1 r START c \->ARRY DEPTH ROLLD NEXT 1 r START DEPTH ROLL NEXT
   1 r START 0 's' STO
    1 c FOR z IF DUP z GET 0 \=/ THEN z 's' STO c 'z' STO END NEXT
    IF s 0 > THEN DUP s GET IF 1 \=/ THEN DUP s GET / END
     1 r 1 - START
      r ROLL IF DUP s GET 0 \=/ THEN DUP2 s GET * - 1 'n' STO END SWAP
     NEXT
    END
    r ROLLD
   NEXT
   r 'n' STO
   1 c FOR z 1 r FOR y
     IF DUP z GET 1 == THEN
      n ROLLD 'n' DECR IF 1 == THEN r 'y' STO c 'z' STO END ELSE n ROLLD END
   NEXT NEXT
  1 r START DEPTH ROLLD NEXT 1 r START DEPTH ROLL OBJ\-> DROP NEXT
  r c 2 \->LIST \->ARRY
\>> \>> \>>
---------------------------------------------------------------------------

>Mats Olsson
>Chalmers University of technology
>Sweden
-- 

 "Hi, we're 'Slaughter'.  We'd just like to say how much we love our troops."

Pete Ashdown  pashdown@javelin.sim.es.com ...uunet!javelin.sim.es.com!pashdown

TDSTRONG%MTUS5.BITNET@CUNYVM.CUNY.EDU (Tim Strong) (02/17/91)

>
>>Actually Matt you're not missing it in the manuals.  HP did not include
>>this feature in the calcualtor since I believe its only use is in solving
>>multivariable linear equations.  This is much more easily accomplished
>>on the HP by the following method:
>...
>>Then press the divide key and the answers are on the stack in the form:
>-----
>
>The method described above does only work for quadratic systems of equations.
>
Good point!  I haven't had linear algebra for a long time and I'd
forgotten about that one.

======================================================================
  ___
  :__)  _   _:  _   _   Tim Strong <tdstrong%mtus5.bitnet@cunyvm.edu>
  :  \ (_: (_: (_: :    Michigan Tech.    Houghton, Michigan

======================================================================

jcohen@lehi3b15.csee.Lehigh.EDU (Josh Cohen [890918]) (02/22/91)

Row reducing, dont fret!	
it can be done and I have just the program to do it.. I got it from
wuarchive, i believe... written for the 28s.... ( should work on 48)
mail me if you cant get it
jcohen@scarecrow.csee.lehigh.edu

pashdown@javelin.es.com (Pete Ashdown) (02/25/91)

jcohen@lehi3b15.csee.Lehigh.EDU (Josh Cohen [890918]) writes:

>Row reducing, dont fret!	
>it can be done and I have just the program to do it.. I got it from
>wuarchive, i believe... written for the 28s.... ( should work on 48)
>mail me if you cant get it
>jcohen@scarecrow.csee.lehigh.edu

*SIGH*  I posted this a couple of weeks ago.  I tried the one for the 28s
as well, it works, but it is about three times as big.  Here is the program:

%%HP: T(3)A(R)F(.);
@ RWRD - Matrix Row Reduction ( matrix - reduced matrix )
@ Robert T. Wilson - University of Iowa
\<< DUP OBJ\-> OBJ\-> DROP \-> r c \<< r r 1 \-> m n s \<< 
   1 r START c \->ARRY DEPTH ROLLD NEXT 1 r START DEPTH ROLL NEXT
   1 r START 0 's' STO
    1 c FOR z IF DUP z GET 0 \=/ THEN z 's' STO c 'z' STO END NEXT
    IF s 0 > THEN DUP s GET IF 1 \=/ THEN DUP s GET / END
     1 r 1 - START
      r ROLL IF DUP s GET 0 \=/ THEN DUP2 s GET * - 1 'n' STO END SWAP
     NEXT
    END
    r ROLLD
   NEXT
   r 'n' STO
   1 c FOR z 1 r FOR y
     IF DUP z GET 1 == THEN
      n ROLLD 'n' DECR IF 1 == THEN r 'y' STO c 'z' STO END ELSE n ROLLD END
   NEXT NEXT
  1 r START DEPTH ROLLD NEXT 1 r START DEPTH ROLL OBJ\-> DROP NEXT
  r c 2 \->LIST \->ARRY
\>> \>> \>>

Works great! Less filling!
-- 
		"If the real Jesus Christ were to stand up today
		 He'd be gunned down cold by the CIA"  - The The

Pete Ashdown  pashdown@javelin.sim.es.com ...uunet!javelin.sim.es.com!pashdown