## HP 50g: Processing Vectors in Algebraic Mode.

In this blog, we explain the vector or array capabilities of the HP-50g symbolic graphing calculator. My motivation was that the way to access an element, say the first element, is not even shown in the slim basic User's Manual!

To define a vector named A with elements A = [23.1, 45.6, 87.9, 35.0]

In algebraic mode do: Press the [] pair, then enter the following 23.1 SPC 23.1 SPC 45.6 SPC 87.9 SPC 35.0 inside the brackets. Then store to variable A. This would look like, if written out

[23.1 SPC 23.1 SPC 45.6 SPC 87.9 SPC 35.0] sto A.

Vectors are convenient in that a sequence of numbers of any length is processed via a single convenient label.

To access the first element of A, press A(1). Yes indexing starts at 1, not zero, as in C/C++ or Python and using parenthesis not brackets?!!!. Thus to access the kth element we type, A(k).
In RPN mode, enclose the same command in single quotes, like this: 'A(1)' ENTER EVAL.Yes, you need to press additional keys!

To store a value in any position of the vector type in RPN mode: put(vectorname, position, value).
In RPN mode you can directly assign a new value to any position directly: 5 'A(1)' STO

To transform a column vector to/from a row vector or back or transform a list to/from a vector, consult the Advanced users guide pp.9-20+. YOU may need to program the keystrokes to do the operations.

In RPN modes, special functions allows user to form vectors from the operand stack and to dump vector elements to the stack:

• The function $\to{V2}$ forms a two-dimentsional vector of the form [S2, S1], where S1 is the first level stack element.
• The function $\to{V3}$ forms a two-dimentsional vector of the form [S3, S2, S1], where S1 is the first level stack element.
• The function V$\to$ dumps a vector to the stack. The last element is in S1 or top level of stack.

Now that we know how to define vectors or array in this calc, we tabulate several built-in functions available for arrays or vectors. We assume that you have defined vectors A, B and C.

Description HP-50g function
Length or number of elements of A size(A)
Euclidean norm of A, $\sqrt{\sum A[i]^2}$ abs(A)
Addition of 2 vectors of same size A + B
Addition of 3 vectors of same size A + B +C
Scalar multiplication of each elt. k * A, A * k
Scalar division of each elt. A / k
Cross product of two vectors cross(A,B)
Dot product of two vectors dot(A, B)
Augment a vector with number value augment(A, value>

You cannot perform a scalar addition of a constant to each element of a vector,
you will get a "Bad Argument Type" error message.

The most convenient method of creating defining a vector is using the powerful spreadsheet like
matrix wrtiter editor. MTRW,
which is the third key in the fourth row from the top row of the calculator keys.

Here is an example to illustrate using the matrix editor:

Press LSHIFT MTRW.
Ensure that you are entering row wise mode by selecting Go $\to$. There should be a white box at its right. Just press ENTER key when you are done entering the elements of the vector.

The basic vector processing of the HP50g may seem adequate for normal use. Power users naturally wants Python type array processing capabilities, like extending or appending, and slicing, and negative indices. Hopefully better versions of the library will be available in the future. We will add more interesting routines for vectors in this blog entry in the future.

Revisions:

Date Description
jul.09.2009 First version