![HP 50G User Manual Download Page 698](http://html.mh-extra.com/html/hp/50g/50g_user-manual_156571698.webp)
Page 21-51
A complex IF construct like this is called a set of
nested
IF … THEN … ELSE …
END constructs.
A possible way to evaluate f3(x), based on the nested IF construct shown
above, is to write the program:
«
→
x
«
IF
‘
x<3
‘
THEN
‘
x^2
‘
ELSE IF
‘
x<5
‘
THEN
‘
1-x
‘
ELSE IF
‘
x<3*
π
‘
THEN
‘
SIN(x)
‘
ELSE IF
‘
x<15
‘
THEN
‘
EXP(x)
‘
ELSE –2 END
END END END EVAL
» »
Store the program in variable
@@@f3@@@
and try the following evaluations:
1.5
@@f3@@@
Result
: 2.25 (i.e., x
2
)
2.5
@@@f3@@@
Result
: 6.25 (i.e., x
2
)
4.2
@@@f3@@@
Result
: -3.2 (i.e., 1-x)
5.6
@@@f3@@@
Result
-0.631266… (i.e., sin(x), with x in radians)
12
@@@f3@@@
Result
: 162754.791419 (i.e., exp(x))
23
@@@f3@@@
Result
: -2. (i.e., -2)
The CASE construct
The CASE construct can be used to code several possible program flux paths,
as in the case of the nested IF constructs presented earlier. The general format
of this construct is as follows:
CASE
Logical_statement
1
THEN program_statements
1
END
Logical_statement
2
THEN program_statements
2
END
.
.
.
Logical_statement THEN program_statements END
Default_program_statements (optional)
END
When evaluating this construct, the program tests each of the
logical_statements
until it finds one that is true. The program executes the corresponding
Summary of Contents for 50G
Page 1: ...HP g graphing calculator user s guide H Edition 1 HP part number F2229AA 90006 ...
Page 130: ...Page 2 70 The CMDS CoMmanDS menu activated within the Equation Writer i e O L CMDS ...
Page 206: ...Page 5 29 LIN LNCOLLECT POWEREXPAND SIMPLIFY ...
Page 257: ...Page 7 20 ...
Page 383: ...Page 11 56 Function KER Function MKISOM ...
Page 715: ...Page 21 68 Whereas using RPL there is no problem when loading this program in algebraic mode ...
Page 858: ...Page L 5 ...