HP 50g User's Reference Manual
Download Advanced user's reference manual of HP 48gII Calculator for Free or View it Online on All-Guides.com.
Brand: HP
Category: Calculator
Type: Advanced user's reference manual
Model: HP 48gII , HP 49g+ , HP 50G
Pages: 693
2-4 RPL Programming Examples
FIBT (Comparing Program-Execution Time)
FIB1 calculates intermediate values F
i
more than once, while FIB2 calculates each intermediate F
i
only once.
Consequently, FIB2 is faster. The difference in speed increases with the size of n because the time required for FIB1
grows exponentially with n, while the time required for FIB2 grows only linearly with n.
FIBT executes the TICKS command to record the execution time of FIB1 and FIB2 for a given value of n.
Level 1
→
Level 3 Level 2 Level 1
n
→
F
n
FIB1 TIME: z
FIB2 TIME: z
Techniques used in FIBT
Structured programming.
FIBT calls both FIB1 and FIB2.
Programmatic use of calculator clock.
FIBT executes the TICKS command to record the start and finish of
each subprogram.
Labeling output.
FIBT tags each execution time with a descriptive message.
Required Programs
FIB1 (page 2-1) calculates F
n
using recursion.
FIB2 (page 2-2) calculates F
n
using looping.
FIBT program listing
Program: Comments:
«
DUP TICKS SWAP
FIB1 SWAP TICKS SWAP
Copies n, then executes FIB1, recording the
start and stop time.
- B→R 8192 /
Calculates the elapsed time, converts it to a
real number, and converts that number to
seconds.
Leaves the answer returned by FIB1 in level 2.
"FIB1 TIME" →TAG
Tags the execution time.
ROT TICKS SWAP FIB2
TICKS
Executes FIB2, recording the start and stop
time.
SWAP DROP SWAP
- B→R 8192 /
Drops the answer returned by FIB2 (FIB1
returned the same answer). Calculates the
elapsed time for FIB2 and converts to seconds.
"FIB2 TIME" →TAG
Tags the execution time.
»
`O
FIBT K
Stores the program in FIBT.
Checksum: # 23164d
Bytes: 129