Symbolic Complex Linear System Solver (HP-28S, HP-48G/GX and HP-50g)



#2

This program was written many years ago by Francisco Matheus, one of my classmates back then, originally for the HP-28S. It was particularly useful during Circuit Analysis examinations. The program would accept symbolic equations, no further rearrangement being necessary, which was very impressive.

The author has authorized its free use with the hope it continues to be useful for EE students. No warranty shall be provided though. Test it on your textbook examples before you decide it's suitable for your needs. The HP-48G/GX and HP-50g built-in linear system solver is an option.

1) V1 - V2 = 10*Ix

2) V1/j20 + (V1 - V3)/20 + V2/10 + (V2 - V3)/-j10 = 0

3) V3/j10 + (V3-V2)/-j10 + 2/-45 + (V3 - V1)/20 = 0

4) Ix = -V3/j10

where j = sqrt(-1) and 2/-45 is 2 angle -45 degrees.

As an example, the equations in the linear system above would be entered as

'V1-V2=10*IX'
'V1/(0,20)+(V1-V3)/20+V2/10+(V2-V3)/(0,-10)=0'
'V3/(0,10)+(V3-V2)/(0,-10)+(1.41421356237,-1.41421356237)+(V3-V1)/20=0'
'IX=-V3/(0,10)'

On the HP-28S 2/-45 would have to be previously converted from polar to retangular coordinates. Notice the number of equations could have been reduced to three by substituting eq. 4 in eq. 1, but we'll use the example as it has been presented.

Copy the programs to an empty HP-28S directory. Enter the four equations of the example system, enter the list of unknowns {V1 V2 V3 IX} then run SYS program to solve the linear system. The '<-' program cleans up the directory, that is, it purges all objects at the left of it in the menu.

The lines below can be copied and pasted to Emu42 with an HP-28S ROM and then saved to 'SYS', '<-' and 'EQS', respectively, after applying the STR-> command. ( '<-' should be entered as 142 CHR STR-> )

’ DUP SIZE  l n
’ n LIST 'EQS'
STO 0 n
FOR i 1 n
FOR j i j == 1
0 IFTE l j GET STO
NEXT 1 n
FOR j 'EQS(j)'
NUM
NEXT n ARRY i
IF NOT
THEN NEG 'VET'
STO
ELSE VET +
ARRY DROP
END
NEXT { n n }
ARRY l PURGE TRN
CONJ 'MAT' STO VET
MAT / n 1
FOR i DUP i GET
l i GET STO -1
STEP VET ARRY
DROP { n 1 } ARRY
'VET' STO DROP

’ VARS 1 OVER 'Ž'
POS 1 - SUB PURGE

{ 'V1-V2=10*IX' 'V1/
(0,20)+(V1-V3)/20+V2
/10+(V2-V3)/(0,-10)=
0' 'V3/(0,10)+(V3-V2
)/(0,-10)+
(1.41421356237,-1.41421356237)
+(V3-V1)/20=0' 'IX=-
V3/(0,10)' }

Contents of the directory after the example linear system is solved

HP-28S Version:

--------------------------

V1 (-1.88561808316,
-24.5130350811)
V2 (-1.88561808316,
-5.65685424948)
V3 (-18.8561808316,0)
IX (0,-1.88561808316)
MAT
[[ (1,0) (-1,0) (0,0) (-10,0) ]
[ (.05,-.05) (.1,.1) (-.05,-.1) (0,0) ]
[ (-.05,0) (0,-.1) (.05,0) (0,0) ]
[ (0,0) (0,0) (0,-.1) (1,0) ]]
VET
[[ (0,0) ]
[ (0,0) ]
[ (-1.41421356237,1.41421356237) ]
[ (0,0) ]]
EQS { 'V1-V2=10*IX' 'V1/
(0,20)+(V1-V3)/20+V2
/10+(V2-V3)/(0,-10)=
0' 'V3/(0,10)+(V3-V2
)/(0,-10)+
(1.41421356237,-1.41421356237)
+(V3-V1)/20=0' 'IX=-
V3/(0,10)' }

<-
« VARS 1 OVER '<-'
POS 1 - SUB PURGE
»

SYS
« DUP SIZE \-> l n
« n \->LIST 'EQS'
STO 0 n
FOR i 1 n
FOR j i j == 1
0 IFTE l j GET STO
NEXT 1 n
FOR j 'EQS(j)'
\->NUM
NEXT n \->ARRY i
IF NOT
THEN NEG 'VET'
STO
ELSE VET +
ARRY\-> DROP
END
NEXT { n n }
\->ARRY l PURGE TRN
CONJ 'MAT' STO VET
MAT / n 1
FOR i DUP i GET
l i GET STO -1
STEP VET ARRY\->
DROP { n 1 } \->ARRY
'VET' STO DROP
»
»

--------------------------

HP-48G/GX Version:

On the HP-48G/GX and the HP-50g, the third equation can be entered as

'V3/(0,10)+(V3-V2)/(0,-10)+(2,/-45)+(V3-V1)/20=0'

On the HP-48G/GX the angle symbol '/ ' is accessible through right-shift SPC (ALPHA right-shift 6 on the HP-50g).

--------------------------

%%HP: T(3)A(D)F(.);
DIR
V1 (-1.88561808316,-24.5130350811)
V2 (-1.88561808316,-5.65685424948)
V3 (-18.8561808316,0)
IX (0,-1.88561808316)
MAT
[[ (1,0) (-1,0) (0,0) (-10,0) (0,0) ]
[ (.05,-.05) (.1,.1) (-.05,-.1) (0,0) (0,0) ]
[ (-.05,0) (0,-.1) (.05,0) (0,0) (-1.41421356237,1.41421356237) ]
[ (0,0) (0,0) (0,-.1) (1,0) (0,0) ]]
EQS { 'V1-V2=10*IX' 'V1/(0,20)+(V1-V3)/20+V2/10+(V2-V3)/(0,-10)=0' 'V3/(0,10)+(V3-V2)/(0,-10)+(1.41421356237,-1.41421356237)+(V3-V1)/20=0' 'IX=-V3/(0,10)' }
\183\<-
\<< VARS 1 OVER '\183\<-' POS 1 - SUB PURGE
\>>
SYS
\<< DUP SIZE \-> l n
\<< n \->LIST 'EQS' STO 0 n
FOR i 1 n
FOR j i j == 1 0 IFTE l j GET STO
NEXT 1 n
FOR j 'EQS(j)' \->NUM
NEXT n \->ARRY i
IF NOT
THEN NEG 'VET' STO
ELSE VET + ARRY\-> DROP
END
NEXT { n n } \->ARRY l PURGE TRN CONJ 'MAT' STO VET MAT / n 1
FOR i DUP i GET l i GET STO -1
STEP DROP MAT VET n 1 + COL+ 'MAT' STO 'VET' PURGE
\>>
\>>
END

--------------------------

HP-50g Version:

CAS mode should be set to Complex.

--------------------------
%%HP: T(3)A(D)F(.);
DIR
V1 (-1.88561808316,-24.5130350811)
V2 (-1.88561808317,-5.65685424948)
V3 (-18.8561808316,0.)
IX (0.,-1.88561808316)
MAT
[[ (1.,0.) (-1.,0.) (0.,0.) (-10.,0.) 0. ]
[ (.05,-.05) (.1,.1) (-.05,-.1) (0.,0.) (0.,0.) ]
[ (-.05,0.) (0.,-.1) (.05,0.) (0.,0.) (-1.41421356237,1.41421356237) ]
[ (0.,0.) (0.,0.) (0.,-.1) (1.,0.) (0.,0.) ]]
EQS { 'V1-V2=10*IX' 'V1/(0+20*i)+(V1-V3)/20+V2/10+(V2-V3)/(0+-10*i)=0' 'V3/(0+10*i)+(V3-V2)/(0+-10*i)+(2*COS(-45)+2*SIN(-45)*i)+(V3-V1)/20=0' 'IX=-V3/(0+10*i)' }
\183\<-
\<< VARS 1 OVER '\183\<-' POS 1 - SUB PURGE
\>>
SYS
\<< DUP SIZE \-> l n
\<< n \->LIST 'EQS' STO 0 n
FOR i 1 n
FOR j i j == 1 0 IFTE l j GET STO
NEXT 1 n
FOR j 'EQS(j)' \->NUM
NEXT n \->ARRY i
IF NOT
THEN \->NUM NEG 'VET' STO
ELSE VET + \->NUM ARRY\-> DROP
END
NEXT { n n } \->ARRY l PURGE TRAN 'MAT' STO VET MAT / n 1
FOR i DUP i GET l i GET STO -1
STEP DROP MAT VET n 1 + COL+ 'MAT' STO 'VET' PURGE
\>>
\>>
END

--------------------------


Edited: 13 Mar 2011, 4:00 p.m.


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP 50g : More on best rechargeable batteries Miguel Toro 1 221 12-12-2013, 05:31 PM
Last Post: David Hayden
  hp-prime solver and variable name fabrice48 22 938 12-10-2013, 03:25 AM
Last Post: fabrice48
  HP-48GX & 50G Question Matt Agajanian 2 229 12-08-2013, 10:17 PM
Last Post: Matt Agajanian
  HP Prime: complex numbers in CAS. Alberto Candel 1 187 12-06-2013, 02:36 PM
Last Post: parisse
  HP 50g switching two keys in the user keyboard Sean Freeman 9 493 12-05-2013, 11:44 AM
Last Post: Mark Puscas
  [HP Prime] Plots containing complex numbers bug? Chris Pem10 7 389 12-05-2013, 07:40 AM
Last Post: cyrille de Brébisson
  Solver issue with HP 17BII - different from 19BII Jeff Kearns 13 498 11-28-2013, 02:36 AM
Last Post: Don Shepherd
  HP Prime Triangle solver BruceH 29 1,162 11-28-2013, 12:03 AM
Last Post: Dale Reed
  HP 50g - displaying result in engineering format Sean Freeman 10 530 11-24-2013, 05:44 AM
Last Post: C.Ret
  HP prime: linear solver app Alberto Candel 1 198 11-21-2013, 01:57 AM
Last Post: Michael Carey

Forum Jump: