User rpl programming in algebraic mode – HP 48gII User Manual

Page 715

Advertising
background image

Page 21-66

IF trap-clause THEN error-clause END

IF trap-clause THEN error-clause ELSE normal-clause END


The operation of these logical constructs is similar to that of the IF … THEN …
END and of the IF … THEN … ELSE … END constructs. If an error is
detected during the execution of the trap-clause, then the error-clause is
executed. Otherwise, the normal-clause is executed.

As an example, consider the following program (

@ERR1) that takes as input two

matrices, A and b, and checks if there is an error in the trap clause: A b /
(RPN mode, i.e., A/b). If there is an error, then the program calls function
LSQ (Least SQuares, see Chapter 11) to solve the system of equations:

«

A b

«

IFERR A b / THEN LSQ END

» »


Try it with the arguments A = [ [ 2, 3, 5 ] , [1, 2, 1 ] ] and b = [ [ 5 ] , [ 6 ] ].
A simple division of these two arguments produces an error: /Error: Invalid
Dimension.

However, with the error-trapping construct of the program,

@ERR1, with the

same arguments produces: [0.262295…, 0.442622…].

User RPL programming in algebraic mode

While all the programs presented earlier are produced and run in RPN mode,
you can always type a program in User RPL when in algebraic mode by using
function RPL>. This function is available through the command catalog. As
an example, try creating the following program in algebraic mode, and store
it into variable P2:

«

→ X ‘2.5-3*X^2’ »


First, activate the RPL> function from the command catalog (

‚N). All

functions activated in ALG mode have a pair of parentheses attached to their
name. The RPL> function is not exception, except that the parentheses must be
removed before we type a program in the screen. Use the arrow keys
(

š™) and the delete key (ƒ) to eliminate the parentheses from the RPL>()

Advertising
This manual is related to the following products: