HP 50g Graphing Calculator User Manual

Page 650

Advertising
background image

Page 21-3

use a local variable within the program that is only defined for that program
and will not be available for use after program execution. The previous
program could be modified to read:

«

→ x

«

x SINH 1 x SQ ADD /

» »

The arrow symbol (

) is obtained by combining the right-shift key ‚ with the

0

key, i.e., ‚é. Also, notice that there is an additional set of

programming symbols (« ») indicating the existence of a sub-program, namely «

x SINH 1 x SQ ADD /

», within the main program. The main program starts

with the combination

→ x

, which represents assigning the value in level 1 of

stack to a local variable x. Then, programming flow continues within the sub-
program by placing x in the stack, evaluating SINH(x), placing 1 in the stack,
placing x in the stack, squaring x, adding 1 to x, and dividing stack level 2

(SINH(x)) by stack level 1 (1+x

2

). The program control is then passed back to

the main program, but there are no more commands between the first set of
closing programming symbols (») and the second one, therefore, the program

terminates. The last value in the stack, i.e., SINH(x)/ (1+x

2

), is returned as the

program output.

The variable x in the last version of the program never occupies a place among
the variables in your variable menu. It is operated upon within the calculator
memory without affecting any similarly named variable in your variable menu.
For that reason, the variable x in this case is referred to as a variable local to
the program, i.e., a local variable.

Note: To modify program

@@@g@@@, place the program name in the stack

@@@g@@@ `), then use „˜. Use the arrow keys (š™—˜) to

move about the program. Use the backspace/delete key, ƒ, to delete any
unwanted characters. To add program containers (i.e., « »), use ‚å,
since these symbols come in pairs you will have to enter them at the start and
end of the sub-program and delete one of its components with the delete key
ƒ

to produce the required program, namely:

Advertising