Post Reply 
[WP-34S] Calculations With Complex Matrices
05-18-2014, 05:20 PM (This post was last modified: 05-20-2014 12:15 PM by Thomas Klemm.)
Post: #1
[WP-34S] Calculations With Complex Matrices
Introduction
This article describes how to perform matrix multiplication and matrix inversion with complex matrices. Since the WP-34S lacks complex numbers the same trick as in the HP-15C is used. The complex transformation between \(Z^P\) and \(\tilde{Z}\) is provided by combining M.COPY and M.TRANSP commands. Of course this could be written down in a small program.

MED: Matrix Editor

This description is from matrixedit.wp34s:
Code:
/*
 *  Interactive editor for matrices.
 *  Start the editor with a matrix descriptor in X.
 *  Use the arrow keys to navigate:
 *    up/down: previous/next column
 *    f-up/f-down: previous/next row
 *  Type a digit to enter a number. This will suspend
 *  the progrom. R/S will enter X at the current row/column.
 *  XEQ RCL restores the present value to X if you decide
 *  not to change the cell. Press R/S to continue.
 *
 *  Some hot keys:
 *   A will start over at (1,1).
 *     When used outside the editor you will need to specifiy
 *     a new descriptor first.
 *   B (labeled 1/x) will call M[^-1] on the matrix.
 *   C continues at the last position.
 *   D computes and displays the determinant. R/S or C continue.
 *
 *  We need a few registers for internal use and therefore 
 *  set the stacksize to 4 to free registers A to D.
 *  Press <- to restore the mode and exit the editor.
 *  Double precision mode will always be reset!
 *
 *  Register usage:
 *   A - Matrix descriptor
 *   B - Current register
 *   D - Old setup mode
 *   I, J - Row and column
 *   K last key pressed
 *
 *  Flags:
 *   A - Controls big "=" sign
 *   00 - Shift state
 *
 *  Fixed labels:
 *   A, 11 - Start over with new matrix ('A'gain)
 *   B, 12 - Compute the inverse ('1/x')
 *   C     - Continue with current matrix ('C'ontinue)
 *   14, D - Compute the determinant ('D'eterminant)
 *   22    - [RCL] recalls current matrix element
 *   24    - [f] toggles navigation from horizontal to vertical
 *   31    - [ENTER^] (same as recall)
 *   35    - [<-] Backspace to exit the editor
 *   51    - [^] Navigation up/left
 *   61    - [v] Navigation down/right
 */


HP-15C
Owner's Handbook
Section 12: Calculating With Matrices
Calculating With Complex Matrices


Inverting a Complex Matrix

Example: (pp. 165)

\[Z = \begin{bmatrix} 4+3i & 7-2i \\ 1+5i & 3+8i \end{bmatrix}\]
\[Z^P = \begin{bmatrix}4 & 7 \\ 1 & 3 \\ 3 & -2 \\ 5 & 8\end{bmatrix}\]

Enter matrix \(Z^P\):
0.0402
XEQ 'MED'
4 R/S
↓ 7 R/S
↓ 1 R/S
(…)
↓ 8 R/S


Calculate offset for element (1,3):
1
3
0.0802
MATRIX:M.REG
4


Calculate offset for element (1,5):
1
5
0.0802
MATRIX:M.REG
8


Copy complex 2×2 matrix:
4.0202
8
MATRIX:M.COPY
8.0202


Negate 2×2 matrix (-x = x - 2x):
-2
4.0202
8.0202
MATRIX:M+x


Calculate offset for element (1,1):
1
1
0.0402
MATRIX:M.REG
0


Calculate offset for element (1,7):
1
7
0.0802
MATRIX:M.REG
12


Copy real 2×2 matrix:
0.0202
12
MATRIX:M.COPY
12.0202


Transpose upper 4×2 matrix:
0.0402
MATRIX:TRANSP
0.0204


Transpose lower 4×2 matrix:
8.0402
MATRIX:TRANSP
8.0202


Transpose 4×4 matrix:
0.0404
MATRIX:TRANSP
0.0404


\[\tilde{Z}=\begin{bmatrix} 4 & 7 & -3 & 2 \\ 1 & 3 & -5 & -8 \\ 3 & -2 & 4 & 7 \\ 5 & 8 & 1 & 3 \end{bmatrix}\]

Calculate the inverse:
0.0404
MATRIX:M-1


\[\tilde{Z}^{-1}=\begin{bmatrix} -0.0254 & 0.2420 & 0.2829 & 0.0022 \\ -0.0122 & -0.1017 & -0.1691 & 0.1315 \\ -0.2829 & -0.0022 & -0.0254 & 0.2420 \\ 0.1691 & -0.1315 & -0.0122 & -0.1017 \end{bmatrix}\]

Solving the Complex Equation AX = B

Example: (pp. 169)

\[A^P=\begin{bmatrix} 10 & 0 \\ 0 & 0 \\ 200 & -200 \\ -200 & 170 \end{bmatrix}\]
\[B^P=\begin{bmatrix} 5 \\ 0 \\ 0 \\ 0 \end{bmatrix}\]

Calculate inverse of AP as above and multiply by BP:
0.0404
16.0401
20
MATRIX:M×
20.0401


\[\tilde{A}^{-1}\times B^P=\begin{bmatrix} 0.0372 \\ 0.0437 \\ 0.1311 \\ 0.1543 \end{bmatrix}\]

Transpose 2×2 matrix:
20.0202
MATRIX:TRANSP


\[\begin{bmatrix} 0.0372 & 0.1311 \\ 0.0437 & 0.1543 \end{bmatrix}\]


HP-42S
RPN Scientific
Programming Examples and Techniques
5: Matrices


Solving Simultaneous Equations That Have Complex Terms

Example: (pp. 166)

\[A=\begin{bmatrix} 10-i0.01 & -5 & 0 & 0 \\ -5 & 15-i0.01 & -5 & 0 \\ 0 & -5 & 15-i0.01 & -5 \\ 0 & 0 & -5 & 15-i0.01 \end{bmatrix}\]

\[B=\begin{bmatrix} 34 \\ 0 \\ 0 \\ 0 \end{bmatrix}\]

\[A^P=\begin{bmatrix} 10 & -5 & 0 & 0 \\ -5 & 15 & -5 & 0 \\ 0 & -5 & 15 & -5 \\ 0 & 0 & -5 & 15 \\ -0.01 & 0 & 0 & 0 \\ 0 & -0.01 & 0 & 0 \\ 0 & 0 & -0.01 & 0 \\ 0 & 0 & 0 & -0.01 \end{bmatrix}\]

\[B^P=\begin{bmatrix} 34 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \end{bmatrix}\]

Let's assume we want to preserve registers 0-4. Thus we start with register 5 for matrix AP.

Enter matrix AP:
P.FCN:CLREGS
5.0804
XEQ 'MED'


Calculate offset for element (1,5):
1
5
5.1604
MATRIX:M.REG
21


Calculate offset for element (1,9):
1
9
5.1604
MATRIX:M.REG
37


Copy complex 4×4 matrix:
21.0404
37
MATRIX:M.COPY
37.0404


Negate 4×4 matrix (-x = x - 2x):
-2
21.0404
37.0404
MATRIX:M+x


Calculate offset for element (1,1):
1
1
5.1604
MATRIX:M.REG
5


Calculate offset for element (1,13):
1
13
5.1604
MATRIX:M.REG
53


Copy real 4×4 matrix:
5.0404
53
MATRIX:M.COPY
53.0404


Transpose upper 8×4 matrix:
5.0804
MATRIX:TRANSP
5.0408


Transpose lower 8×4 matrix:
37.0804
MATRIX:TRANSP
37.0408


Transpose 8×8 matrix:
5.0808
MATRIX:TRANSP
5.0808


Enter matrix BP:
70.0801
XEQ 'MED'


Invert matrix A:
5.0808
MATRIX:M-1


Multiply A by B:
5.0808
70.0801
80
MATRIX:M×
80.0801


Transpose 2×4 matrix:
80.0204
MATRIX:TRANSP
80.0402


Result:
\[I=\begin{bmatrix} 4.2000 & 0.0061 \\ 1.600 & 0.0037 \\ 0.6000 & 0.0019 \\ 0.2000 & 0.0008 \end{bmatrix}\]
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)