Flags Oot E E E - HP -11C Owner's Handbook Manual

Hide thumbs Also See for HP-11C:
Table of Contents

Advertisement

Section 11: Programming Techniques
215
3.
Compute the next approximation from the modified guess
and store it.
4.
Recall the value of the previous approximation and subtract
it from the value of the present approximation.
5.
Recall the Ax limit and compare its value with the
magnitude of the difference just computed.
6.
If the magnitude of the difference is greater than that of the
Ax limit continue looping.
7.
If the magnitude of the difference is less than that of the Ax
limit, exit from the loop.
Notice that this method does not guarantee an exit from the loop.
The first guess may have been very far from the actual root, or the
root may not even exist. The best method then is a combination of
the two, as is the method used by this program.
Not at all obvious is the fact that the nature of certain functions is
such that phantom roots may appear. These phantom roots occur
when the slope of the function is so large that the difference
between two consecutive approximations falls within the Ax limit.
This program provides a safeguard against this by testing not only
the loop count and the Ax limit but also the value of the function at
the point in question. The functional value is compared with the
tolerance to see how close to zero the user wants the solution to be.
Flags
When writing a program that deals with different problems in
similar but not identical fashions, flags can be used to control the
differences in the treatment of the data.
Flags serve as reminders. For instance, when the program
performs an optional initial calculation, a flag may be set. Later in
the program we may need to know whether or not the operation
was performed, so we test the flag, i.e., Is flag 0 set? (Was the
operation performed?) In this way, flags are part of the decision-
making power of the calcualtor.
In the Curve Fitting program, three very similar processes may be
performed depending on the choice of curve to be fit. To illustrate
the role of the flags, two more columns may be added to the chart
on page 162.

Advertisement

Table of Contents
loading

Table of Contents