Page 21-17
You can also separate the input data with spaces in a single stack line rather
than using
`
.
Programs that simulate a sequence of stack operations
In this case, the terms to be involved in the sequence of operations are
assumed to be present in the stack. The program is typed in by first opening
the program containers with
‚å
. Next, the sequence of operations to
be performed is entered. When all the operations have been typed in, press
`
to complete the program. If this is to be a once-only program, you can
at this point, press
µ
to execute the program using the input data available.
If it is to be a permanent program, it needs to be stored in a variable name.
The best way to describe this type of programs is with an example:
Example
:
Velocity head for a rectangular channel
.
Suppose that we want to calculate the velocity head, h
v
, in a rectangular
channel of width b, with a flow depth y, that carries a discharge Q. The
specific energy is calculated as h
v
= Q
2
/(2g(by)
2
), where g is the acceleration
of gravity (g = 9.806 m/s
2
in S.I. units or g = 32.2 ft/s
2
in E.S. units). If we
were to calculate h
v
for Q = 23 cfs (cubic feet per second = ft
3
/s), b = 3 ft,
and y = 2 ft, we would use: h
v
= 23
2
/(2
⋅
32.2
⋅
(3
⋅
2)
2
). Using the RPN
modethe calculator, interactively, we can calculate this quantity as:
2`3*„º32.2*
2*23㼪/
Resulting in 0.228174, or h
v
= 0.228174.
To put this calculation together as a program we need to have the input data
(Q, g, b, y) in the stack in the order in which they will be used in the
calculation. In terms of the variables Q, g, b, and y, the calculation just
performed is written as (do not type the following):
y
`
b
*„º
g
*2*
Q
㼪/