While this simple construct works fine when your function has only two
branches, you may need to nest IF...THEN...ELSE...END constructs to deal
with function with three or more branches.
function
f
Here is a possible way to evaluate this function using IF... THEN ... ELSE ...
END constructs:
IF x<3 THEN
2
x
ELSE
IF x<5 THEN
1-x
ELSE
IF x<3π
ELSE
END
END
END
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:
For example, consider the
2
x
,
if
x
1
x
,
if
3
(
x
)
sin(
x
),
if
5
3
exp(
x
),
if
3
π
, 2
elsewhere
THEN
sin(x)
IF x<15 THEN
exp(x)
ELSE
-2
END
3
x
5
x
3
π
x
15
Page 21-50