Thompson - Computing for Scientists and Engineers (523188), страница 3
Текст из файла (страница 3)
Thus, after workingthrough this book, when you tackle an unfamiliar computing task you will often recognize parts that relate to topics in this book, and you can then probably master thetask effectively.Therefore I have not attempted an exhaustive (and exhausting) spread of topics.To continue the culinary analogs, once you have learned how to make a good vanillaice cream you can probably concoct 30 other varieties and flavors. I prefer to examine various facets of each topic, from mathematical analysis, through appropriate numerical methods, to computer programs and their applications. In this book, therefore, you will usually find the presentation of a topic in this order: analysis, numerics, and applications.The level I have aimed at for mathematical and computational sophistication, aswell as for scientific applications, is a middle ground.
The applications themselvesdo not require expert knowledge in the fields from which they derive, although I4INTRODUCTIONgive appropriate background references. Although I present several topics that arealso in my earlier book, Computing in Applied Science (Thompson, 1984), the preliminary and review materials in this book are always more condensed, while the developments are carried further and with more rigor. The background level necessaryfor the mathematics used in this book is available from mathematics texts such asthat by Wylie and Barrett, and also from the calculus text by Taylor and Mann.Diversions and new routesIn order to broaden your scientific horizons and interests, I have included a few diversion sections.
These are intended to point out the conceptual connections between the topic under development and the wider world of science, technology, andthe useful arts.The diversions include a discussion of the interpretation of complex numbers (inSection 2.5), the relationships between recursion in mathematics and computing(Section 3.4), the development of computers and the growing use of spline methodsin data analysis (Section 5.6), and the Wilbraham-Gibbs overshoot in the Fourierseries of discontinuous functions (Section 9.6). Other connections are indicated insubsections of various chapters. Although these diversions may not necessarily beof much help in making you an expert in your field of endeavor, they will help youto appreciate how your field fits into the larger scientific landscape.This book also uses some seldom-traveled routes to reach known destinations,as well as a few tracks that are quite new.
These routes and their results include linearized square-root approximations (Section 3.3), the relations between maximumlikelihood, least squares, and Fourier expansion methods (Sections 6.1, 6.2, 9.2),algorithms for least-squares normalization factors (Section 6.4), logarithmic transformations and parameter biases (Section 6.5), generalized logistic growth (Section 7.3), a novel approach to catenaries (Section 8.2), the discrete and integralFourier transforms of the complex-exponential function (Sections 9.2 and 10.2),and the Wilbraham-Gibbs overshoot (Section 9.6).Roads not takenBecause this book is directed to a readership of mathematicians, scientists, engineers, and other professionals who may be starting work in fields from which examples in this book are drawn, there are many byways that I have not ventured upon.Rather, I emphasize principles and methods that are of both general validity and general applicability.One road not taken is the one leading to topics from linear algebra (except incidentally) and matrix manipulation.
Mathematics texts are replete with examples ofmethods for 3 x 3 matrices, many of which will usually fail for matrices of typically interesting size of 100 x 100. I believe that matrix computation is best taughtand handled numerically by using the powerful and somewhat advanced methodsspecially developed for computers, rather than methods that are simply extensions ofmethods suitable for hand calculations on small matrices.1.2COMPUTING, PROGRAMMING, CODING5Symbolic calculation, also misleadingly termed “computer algebra,” is not discussed here either. I believe that it is dangerous to just “give it to the computer”when mathematical analysis is necessary.
Machines should certainly be used tosolve long and tedious problems reliably and to display results graphically. However, the human who sets up the problem for the computer should always understand clearly the problem that is being solved. This is not likely to be so if most ofone’s training has been through the wizardry of the computer. I have the same objection to the overuse of applications programs for numerical work until the principles have been mastered.
(Of course, that’s one reason to set oneself the task ofwriting a book such as this.) In spite of my warnings, when you have the appropriate understanding of topics, you should master systems for doing mathematics bycomputer, such as those described in Wolfram’s Mathematica.Finally, I have deliberately omitted descriptions of computational methods thatare optimized for specialized computer designs, such as vectorized or parallel architectures.
You should leam and use these methods when you need them, but most ofthem are developed from the simpler principles that I hope you will learn from thisbook. You can become informed on both parallel computation and matrix methodsby reading the book by Modi.1.2 COMPUTING, PROGRAMMING, CODINGWhen computing numerically there are three levels that I envision in problem analysis: program design, coding, and testing.
They are best described by Figure 1.2.FIGURE 1.2 Computing, programming, and coding form a nested hierarchy. An example ofthis nesting activity is that of converting between coordinates (Section 2.6).6INTRODUCTIONIn Figure 1.2 the activity of computing includes programming, which includescoding. The right side of the figure shows the example of converting between Cartesian and polar coordinates — the programming project described in Section 2.6.The aspects of computing that lie outside programming and coding are numericalanalysis and (to some degree) algorithm design. In the example, the formulas forcalculating coordinates are part of numerical analysis, while deciding how quadrantsare selected is probably best considered as part of algorithm design.At the programming level one first has to decide what one wants to calculate, thatis, what output the program should produce.
Then one decides what input is neededto achieve this. One can then decide on the overall structure of the program; for example, the conversions for Cartesian and polar coordinates are probably best handled by separate branches in the program. At this level the choices of computing system and programming language usually become important.Finally, as shown in Figure 1.2, one reaches the coding level. Here the program is built up from the language elements. In the C language, for example, functions are written or obtained from function libraries, variable types are declared, andvariables are shared between functions.
Detailed instructions are coded, the interfaces to files or graphics are written, and the program is tested for corectness of formulas and program control, such as the method used to terminate program execution. If you think of the activity of computing as a nested three-level system, asschematized in Figure 1.2, then you will probably produce better results faster thanif you let your thoughts and actions become jumbled together like wet crabs scuttlingin a fishing basket.In the following parts of this section, I make remarks and give suggestions aboutprogramming as described in this book.
First, I justify my choice of C as the language for preparing the programs, then I give you some pointers for learning to program in C, and for translating the programs in this book to Fortran or Pascal from C(if you insist on doing this). Next, I summarize programming aspects of the projects that occur toward the end of each of Chapters 2 through 10, and I remark onthe correctness and portability of these programs. Finally in this section, I drawyour attention to a convenience, namely, that all the programs and functions provided in this book are listed by section and topic in the index to computer programsbefore the main index.The C language for the programsI decided to write the sample programs in C language for the following reasons.First, C is a language that encourages clear program structure, which leads to programs that are readable.
My experience is that C is easier to write than Pascal because the logic of the program is usually clearer. For example, the use of a topdown structure in the programs is closer to the way scientists and enginners tacklereal problems. In this aspect C and Fortran are similar. The C language is more demanding than Fortran, in that what you want to do and the meanings of the variablesmust all be specified more accurately. Surprisingly, scientists (who pride themselves on precise language) often object to this demand from a computer. I estimate1.2 COMPUTING, PROGRAMMING, CODING7that C is the easiest of the three languages in which to write programs that arenumerically oriented.
Ease is indicated by the time it takes to produce a correctlyexecuting program in each language.The second reason for using C in this book is that it is intermediate in complexitybetween Fortran and Pascal, as illustrated by the comparison chart in the appendix.That is, there are very few elements in the Fortran language (which makes it simpleto write but hard to understand), most of the elements of Fortran are in C, and someof the elements of Pascal are also in C. For data handling, C is much more powerfuland convenient than Fortran because facilities for handling characters and stringswere designed into the original C language.The third reason for my choice of C is that it is now the language of choice forwriting applications programs for workstations and personal computers.