Trident Help

RPN Advanced 42 manual · Chapter 10 of 18

Matrices and vectors

Create, edit, invert and multiply matrices, solve linear systems, and use dot and cross products.

10.1The MATRIX menu#

Open MATRIX with shift 9. A matrix is one value on the stack, shown as [ 2×2 Matrix ]. You can store it in a register or a named variable. Entries are real numbers.

MATRIX page 1. The display shows: x: 0.0000 / NEW INV DET TRN SMQ EDT.
MATRIX page 1.
MATRIX page 2. The display shows: x: 0.0000 / DOT CRS UVC DIM IDX EDN.
MATRIX page 2.
LabelWhat it does
NEWMakes a zero matrix. Y = rows, X = columns.
INVInverse of the matrix in X.
DETDeterminant of the matrix in X.
TRNTranspose.
SMQSolve simultaneous equations (SIMQ).
EDTEdit the matrix in X.
DOT (page 2)Dot product of two vectors.
CRSCross product of two 3-element vectors.
UVCUnit vector: divides a vector by its length.
DIMCreates or resizes a named matrix (Y rows, X columns).
EDNEdits a named matrix.

10.2Create and edit a matrix#

NEW makes a zero matrix, and EDIT opens it in the matrix editor. The top line shows row:column=value. Type a number and press the right-arrow menu key (→) to store it and move on. ENTER does the same as →: it stores the number and moves to the next element (after the last element it wraps to the first). Press EXIT to leave the editor; your edits are kept.

The matrix editor on a new 2 by 2 matrix. Menu keys: insert row, left, up, down, right, delete row. The display shows: 1:1=0.0000 / INS  ←   ↑   ↓   →  DEL.
The matrix editor on a new 2 by 2 matrix. Menu keys: insert row, left, up, down, right, delete row.
Menu keyLabelAction
Σ+INSInsert a row of zeros before the current row.
1/x←Move left (stores the number you were typing).
√x↑Move up.
LOG↓Move down.
LN→Move right.
XEQDELDelete the current row.

The ▲ and ▼ keys also move between rows. Moving past the last cell wraps around to the first.

Example 10.1

Build [[1, 2], [3, 4]]

  1. Type 2, ENTER, 2 and press NEW (first key).

    2ENTER2⇧MATRIX9Σ+
  2. Press EDIT (sixth key). Type each number and press → (fifth key); type the last number and EXIT.

    XEQ1LN2LN3LN4EXIT
    After step 2: Press EDIT (sixth key). Type each number and press → (fifth key); type the last number and EXIT. The display shows: x: [ 2×2 Matrix ] / NEW INV DET TRN SMQ EDT.
Result of the example "Build [[1, 2], [3, 4]]" The display shows: x: [ 2×2 Matrix ] / NEW INV DET TRN SMQ EDT.
You should see[ 2×2 Matrix ]
Example 10.2

Check the editor shows the values

  1. After building the matrix, open EDIT again and move right.

    2ENTER2⇧MATRIX9Σ+XEQ1LN2LN3LN4EXITXEQLN
Result of the example "Check the editor shows the values" The display shows: 1:2=2.0000 / INS  ←   ↑   ↓   →  DEL.
You should see1:2=2.0000

10.3Determinant, inverse and transpose#

det⁡(1234)=1⋅4−2⋅3=−2\det\begin{pmatrix}1&2\\3&4\end{pmatrix}=1\cdot4-2\cdot3=-2
Example 10.3

Determinant of [[1,2],[3,4]]

  1. Build the matrix and press DET (third key).

    2ENTER2⇧MATRIX9Σ+XEQ1LN2LN3LN4EXIT√x
Result of the example "Determinant of [[1,2],[3,4]]" The display shows: x: -2.0000 / NEW INV DET TRN SMQ EDT.
You should see-2.0000
Example 10.4

Inverse: look at the first entry

  1. Build the matrix and press INV (second key).

    2ENTER2⇧MATRIX9Σ+XEQ1LN2LN3LN4EXIT1/x
  2. Open the editor to read it: the first value is −2.

    XEQ
    After step 2: Open the editor to read it: the first value is −2. The display shows: 1:1=-2.0000 / INS  ←   ↑   ↓   →  DEL.
Result of the example "Inverse: look at the first entry" The display shows: 1:1=-2.0000 / INS  ←   ↑   ↓   →  DEL.
You should see1:1=-2.0000
Example 10.5

Transpose

  1. Build the matrix and press TRN (fourth key); the entry at 1:2 is now 3.

    2ENTER2⇧MATRIX9Σ+XEQ1LN2LN3LN4EXITLOGXEQLN
Result of the example "Transpose" The display shows: 1:2=3.0000 / INS  ←   ↑   ↓   →  DEL.
You should see1:2=3.0000

For matrices up to 10 × 10, DET, INV, ÷ and SIMQ are worked out exactly from the 12-digit entries and rounded once at the end. So a singular matrix of whole numbers has a determinant of exactly 0, and the inverse of a matrix with simple fractions comes out right to the last digit. Larger matrices use 32-digit elimination.

Example 10.6

A singular 3 × 3 matrix

  1. Make a 3 × 3 matrix and fill it with 1 to 9 by rows.

    3ENTER3⇧MATRIX9Σ+XEQ1LN2LN3LN4LN5LN6LN7LN8LN9EXIT
  2. Press DET: the rows depend on each other, so it is exactly zero.

    √x
Result of the example "A singular 3 × 3 matrix" The display shows: x: 0.0000 / NEW INV DET TRN SMQ EDT.
You should see0.0000
Example 10.7

Its inverse does not exist

  1. Build the same matrix and press INV.

    3ENTER3⇧MATRIX9Σ+XEQ1LN2LN3LN4LN5LN6LN7LN8LN9EXIT1/x
Result of the example "Its inverse does not exist" The display shows: Singular Matrix / NEW INV DET TRN SMQ EDT.
You should seeSingular Matrix

10.4Add, multiply and scale matrices#

The ordinary operations work on matrices: + and − need matrices of the same size, × multiplies a matrix by a number or by a matrix with matching inner size, and ÷ solves a linear system when Y is the right-hand side matrix and X the coefficient matrix.

Example 10.8

Square a matrix

  1. Build [[1,2],[3,4]], duplicate it with ENTER and multiply.

    2ENTER2⇧MATRIX9Σ+XEQ1LN2LN3LN4EXITEXITEXITENTER×⇧MATRIX9XEQ
Result of the example "Square a matrix" The display shows: 1:1=7.0000 / INS  ←   ↑   ↓   →  DEL.
You should see1:1=7.0000
Example 10.9

Multiply by a number

  1. The first entry of 2 times the matrix is 2.

    2ENTER2⇧MATRIX9Σ+XEQ1LN2LN3LN4EXITEXITEXIT2×⇧MATRIX9XEQ
Result of the example "Multiply by a number" The display shows: 1:1=2.0000 / INS  ←   ↑   ↓   →  DEL.
You should see1:1=2.0000

10.5Solve a system of equations#

SIMQ solves Ax=bA\mathbf{x}=\mathbf{b}. Type the number of equations and press SMQ. The menu offers A (coefficients), B (right-hand sides) and X (the answer). Edit A and B, then press X to compute and show the solution.

x+y=3x−y=1⇒x=2,  y=1\begin{aligned}x+y&=3\\x-y&=1\end{aligned}\quad\Rightarrow\quad x=2,\; y=1
Example 10.10

Solve x + y = 3 and x − y = 1

  1. Type 2 and press SIMQ (fifth key). Edit matrix A (first key): 1, 1, 1, −1.

    2⇧MATRIX9LNΣ+1LN1LN1LN1+/−EXIT
    After step 1: Type 2 and press SIMQ (fifth key). Edit matrix A (first key): 1, 1, 1, −1. The display shows: x: 2.0000 /  A   B   X             .
  2. Edit B (second key): 3 and 1.

    1/x3LN1EXIT
  3. Press X (third key). The editor shows x in row 1.

    √x
Result of the example "Solve x + y = 3 and x − y = 1" The display shows: 1:1=2.0000 / INS  ←   ↑   ↓   →  DEL.
You should see1:1=2.0000

10.6Dot product, cross product and unit vectors#

A vector is a matrix with one row or one column. DOT needs two vectors of the same length. CRS needs two vectors of length 3. UVC divides a vector by its length.

Example 10.11

Dot product of (1,0,0) and (0,1,0)

  1. Build both vectors with NEW 1 × 3 and EDIT.

    1ENTER3⇧MATRIX9Σ+XEQ1LN0LN0EXITEXITEXIT1ENTER3⇧MATRIX9Σ+XEQ0LN1LN0EXIT
  2. Open page 2 and press DOT.

    ▼Σ+
Result of the example "Dot product of (1,0,0) and (0,1,0)" The display shows: x: 0.0000 / DOT CRS UVC DIM IDX EDN.
You should see0.0000
Example 10.12

Unit vector of (3, 4)

  1. Build the vector, open page 2 and press UVC (third key).

    1ENTER2⇧MATRIX9Σ+XEQ3LN4EXIT▼√x
  2. Open the editor: the first value is 0.6.

    ⇧MATRIX9XEQ
Result of the example "Unit vector of (3, 4)" The display shows: 1:1=0.6000 / INS  ←   ↑   ↓   →  DEL.
You should see1:1=0.6000

10.7Read and write single elements: INDEX, STOIJ, STOEL, RCLEL#

INDEX (page 2, fifth key) chooses a named matrix to work on one element at a time. Its pointer starts at row 1, column 1. Page 3 has STOIJ (move the pointer to row Y, column X), RCLIJ (recall the row and column), STOEL (store X in the element), RCLEL (recall the element), PUTM (copy the matrix in X into it, from the pointer) and GETM (copy out a block of Y rows and X columns). Page 4 has INSR and DELR (insert or delete the row at the pointer), R↔R (swap rows Y and X), GRW and WRP, and DM? (the size of the matrix in X: rows in Y, columns in X). Page 5 has I+, I−, J+ and J− to step the pointer down a column or along a row.

Example 10.13

Store and read one element

  1. Make a named 2 × 2 matrix M with DIM, then press INDEX and pick M.

    2ENTER2⇧MATRIX9▼LOG√xLOGENTERLNΣ+
  2. Go to page 3. Move to row 2, column 1 with STOIJ, store 7 with STOEL and read it back with RCLEL.

    ▼2ENTER1Σ+7√xLOG
    After step 2: Go to page 3. Move to row 2, column 1 with STOIJ, store 7 with STOEL and read it back with RCLEL. The display shows: x: 7.0000 / SIJ RIJ SEL REL PTM GTM.
Result of the example "Store and read one element" The display shows: x: 7.0000 / SIJ RIJ SEL REL PTM GTM.
You should seex: 7.0000

10.8Norms and row sums#

NRM on page 5 opens FNM (the Frobenius norm, the square root of the sum of the squares of all elements) and RNM (the row norm: the largest sum of absolute values in a row). RSM gives a column of the row sums.

Example 10.14

Row norm of [[1, −2], [3, 4]]

  1. Build the matrix, go to page 5 (▲ from page 1), press NRM and RNM.

    2ENTER2⇧MATRIX9Σ+XEQ1LN2+/−LN3LN4EXIT▲XEQ1/x
Result of the example "Row norm of [[1, −2], [3, 4]]" The display shows: x: 7.0000 / FNM RNM                .
You should seex: 7.0000

One-number functions such as x², √x, LN, SIN, ABS, IP, FP, RND and SIGN work on each element of a real matrix. To multiply a matrix by itself, use ENTER ×.

10.9Name and store matrices#

DIM (page 2, fourth key) makes a named matrix of Y rows and X columns. EDN opens a named matrix for editing. A matrix can also be stored with STO into a register or variable, and recalled with RCL.

Example 10.15

Make a named 2 by 3 matrix

  1. Type 2, ENTER, 3, open page 2 and press DIM. Type M (group J K L M, fourth key) and ENTER.

    2ENTER3⇧MATRIX9▼LOG√xLOGENTER
  2. Recall it.

    EXITRCL⇧ALPHAENTER√xLOGENTER
Result of the example "Make a named 2 by 3 matrix" The display shows: y: 3.0000 / x: [ 2×3 Matrix ].
You should see[ 2×3 Matrix ]
Example 10.16

Store a matrix in a register

  1. Build [[1,2],[3,4]], store it in register 00 and recall it.

    2ENTER2⇧MATRIX9Σ+XEQ1LN2LN3LN4EXITSTO000RCL00
Result of the example "Store a matrix in a register" The display shows: x: [ 2×2 Matrix ] / NEW INV DET TRN SMQ EDT.
You should see[ 2×2 Matrix ]

HP-42S is a trademark of HP Inc.. Trident Calculator is an independent product by South View Studios and is not affiliated with, sponsored by or endorsed by HP. The name is used only to describe the kind of calculator this model resembles; Trident's names, keys, display, fonts and software are its own clean-room design.