# Programs That Simulate A Sequence Of Stack Operations - HP 50g User Manual

Graphing calculator.

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
, in a rectangular
v
channel of width b, with a flow depth y, that carries a discharge Q. The
2
2
specific energy is calculated as h
= Q
/(2g(by)
), where g is the acceleration
v
2
2
of gravity (g = 9.806 m/s
in S.I. units or g = 32.2 ft/s
in E.S. units). If we
3
were to calculate h
for Q = 23 cfs (cubic feet per second = ft
/s), b = 3 ft, and
v
2
2
y = 2 ft, we would use: h
= 23
/(2 32.2 (3 2)
). Using the RPN modethe
v
calculator, interactively, we can calculate this quantity as:
2`3*„º32.2*
2*23„º™/
Resulting in 0.228174, or h
= 0.228174.
v
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 „º™/
Page 21-17  