Looping Ittt - HP -11C Owner's Handbook Manual

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

Advertisement

214
Section 11: Programming Techniques
Looping
The Newton's Method program deals with the common problem of
approximating a solution to an equation. Such approximations are
necessary because finding an exact root to certain functions is
often difficult and sometimes impossible.
In Newton's Method, we choose a point x at which the function f(x)
exists and, we hope, is close to a root of the function. (Applying a
little basic algebra will help narrow the guessing range.) What goes
on next is to adjust the guess, calculating a closer approximation of
the root based on the initial guess. The calculated value is then
used to calculate another closer approximation. This process is
repeated with the new guess until, in the limit of an infinite number
of repetitions, the exact solution may be reached.
We see that a section of the program must be repeated over and
over again in succession until we get the answer we desire. Such a
section is called a "loop". (The main loop in this program is
between lines 026 and 052.) Of course, an infinite number of
repetitions implies an infinite period of time, so we must set a
boundary on the number of iterations performed.
One method of setting this boundary would be to insert a counter in
the loop such that after each pass through the loop a certain
register will have been incremented by one. The total number of
repetitions is compared with a desired maximum. The program will
then exit from the loop when the two values are equal. (In this
program, the maximum is decremented each time and the loop
terminates when the value has gone to zero. See line 051.) Notice
that this method does not ensure any standard of accuracy. Also,
depending on the function and the guess, finding a reasonable
answer may take an unreasonable number of repetitions. In other
words, stopping the process at even one-hundred repetitions may
yield an answer so far from the actual root as to be useless.
A preferable method is to test the last two computed values to see
whether or not they are significantly different. This difference,
called the Ax limit, is up to the user and is input when initializing
the program.
The format for such a loop is as follows:
1.
Store the Ax limit and the initial guess.
2.
Compute the first approximation from the guess and store it.

Advertisement

Table of Contents
loading

Table of Contents