# Examples Of Sequential Programming,; Programs Generated By Defining A Function, - HP 49g+ User Manual

Graphing calculator.

Examples of sequential programming
In general, a program is any sequence of calculator instructions enclosed
between the program containers " and ". Subprograms can be included as
part of a program. The examples presented previously in this guide (e.g., in
Chapters 3 and 8) 6 can be classified basically into two types: (a) programs
generated by defining a function; and, (b) programs that simulate a sequence
of stack operations. These two types of programs are described next. The
general form of these programs is input process output, therefore, we refer
to them as sequential programs.
Programs generated by defining a function
These are programs generated by using function DEFINE („à) with an
argument of the form:
'function_name(x
, x
1
The program is stored in a variable called function_name.
program is recalled to the stack, by using ‚function_name. The program
shows up as follows:
«
x
, x
, ... 'expression containing variables x
1
2
To evaluate the function for a set of input variables
enter the variables into the stack in the appropriate order (i.e.,
x
,
followed by
then
2
function_name.
The calculator will return the value of the function
function_name
(
x
, x
, ...
).
1
2
Example: Manning's equation for wide rectangular channel.
As an example, consider the following equation that calculates the unit
discharge (discharge per unit width), q, in a wide rectangular open channel
using Manning's equation:
, ...) = expression containing variables x
2
x
,
etc.), and press the soft menu key labeled
3
C
5
3 /
q
=
u
y
S
0
0
n
, x
, ...'
1
2
When the
, x
, ...'".
1
2
x
, x
, ...
, in RPN mode,
1
2
x
first,
1
Page 21-15  