Page 14 - Compact Numerical Methods For Computers
P. 14
4 Compact numerical methods for computers
cannot be acquired simply and must, therefore, be written in-house. There are also a
number of portable computers now available. This text is being entered on a Tandy
Radio Shack TRS-80 Model 100, which is only the size of a large book and is
powered by four penlight batteries.
Users of the various types of machines mentioned above often do not have much
choice as to the programming tools available. On ‘borrowed’ computers, one has to
put up with the compilers and interpreters provided by the user who has paid for the
resource. On portables, the choices may be limited by the decisions of the manufac-
turer. In practice, I have, until recently, mostly programmed in BASIC, despite its
limitations, since it has at least been workable on most of the machines available to
me.
Another group of users of the material in this book is likely to be software
developers. Some scenarios which have occurred are:
—software is being developed in a particular computing environment (e.g. LISP
for artificial intelligence) and a calculation is required for which suitable off-the-shelf
routines are not available;
—standard routines exist but when linked into the package cause the executable
code to be too large for the intended disk storage or memory;
—standard routines exist, but the coding is incompatible with the compiler or
interpreter at hand.
It is worth mentioning that programming language standards have undergone
considerable development in the last decade. Nevertheless, the goal of portable
source codes of numerical methods is still only won by careful and conservative
programming practices.
Because of the emphasis on the needs of the user to program the methods, there is
considerable concern in this book to keep the length and complexity of the
algorithms to a minimum. Ideally, I like program codes for the algorithms to be no
longer than a page of typed material, and at worse, less than three pages. This makes
it feasible to implement the algorithms in a single work session. However, even this
level of effort is likely to be considered tedious and it is unnecessary if the code can be
provided in a suitable form. Here we provide source code in Turbo Pascal for the
algorithms in this book and for the driver and support routines to run them (under
Turbo Pascal version 3.01a).
The philosophy behind this book remains one of working with available tools
rather than complaining that better ones exist, albeit not easily accessible. This
should not lead to complacency in dealing with the machine but rather to an active
wariness of any and every feature of the system. A number of these can and should be
checked by using programming devices which force the system to reveal itself in spite
of the declarations in the manual(s). Others will have to be determined by exploring
every error possibility when a program fails to produce expected results. In most
cases programmer error is to blame, but I have encountered at least one system error
in each of the systems I have used seriously. For instance, trigonometric functions are
usually computed by power series approximation. However, these approximations
have validity over specified domains, usually [0, p /2] or [0, p /2] (see Abramowitz and
Stegun 1965, p 76). Thus the argument of the function must first be transformed to