← Scientific Programming with Macintosh Pascal 1986

Scientific Programming with Macintosh Pascal 1986

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

Image 1

SCIENTIFIC PROGRAMMING WITH MACINTOSH PASCAL RICHARD E. CRANDALL MARIANNE M. COLGROVE

Book cover with a dark background showing a microscope on the left, a Macintosh computer with keyboard in the center, a glass sphere and mortar and pestle on the right, all on a blue and red striped perspective surface, with the title in large cream letters at top and author names in the lower right.

Printed product names
Macintosh Pascal
Languages
English
PDF page 1

SCIENTIFIC PROGRAMMING WITH MACINTOSH PASCAL RICHARD E. CRANDALL MARIANNE M. COLGROVE

Book cover showing a black microscope, a Macintosh-style computer with keyboard, a glass sphere and a mortar and pestle on a blue and red striped surface against a dark starry background with a red glow.

Reading notes: Title letters are partly overlapped by star and light-streak artwork around 'PROGRAMMING' and 'MACINTOSH', but all words are legible.

Printed product names
Macintosh
Languages
English
PDF page 2

The image is an entirely blank white page with no visible artwork, layout, or printed content.

PDF page 3

OTHER TITLES OF INTEREST FROM THE WILEY PRESS

OTHER TITLES OF INTEREST FROM THE WILEY PRESS WordStar® Without Tears (STG), Ashley & Fernandez Pascal Applications for the Sciences (STG), Richard Crandall Jazz® At Work, Burns & Venit MacBASIC (STG), Fi.nkel & Brown Macintosh™ Logo (STG), Haigh & Radford Excel: A Power User's Guide, Hodgkins Quick Calculus, 2nd Edition (STG), Kleppner & Ramsey Statistics, 3rd Edition (STG), Koosis Electronics, 2nd Edition (STG), Kybett Macintosh™: A Concise Guide to Applications Software, Van Nouhuys Wiley Press books can be used as premiums to promote products or services, for training, or in mail-order catalogs. For information on quantity discounts, please write to the Special Sales Department, John Wiley & Sons, Inc.

Printed product names
WordStar® · Pascal Applications for the Sciences · Jazz® · MacBASIC · Macintosh™ Logo · Excel: A Power User's Guide · Quick Calculus, 2nd Edition · Statistics, 3rd Edition · Electronics, 2nd Edition · Macintosh™: A Concise Guide to Applications Software
Languages
English
PDF page 4

Scientific Programming with Macintosh Pascal

Scientific Programming with Macintosh Pascal Richard E. Crandall Marianne M. Colgrove A Wiley Press Book John Wiley & Sons, Inc. New York• Chichester• Brisbane• Toronto• Singapore

Printed product names
Macintosh Pascal
Languages
English
PDF page 5

Scientific programming with Macintosh PASCAL.

Publisher: Stephen Kippur Editor: Theron Shreve Managing Editor: Katherine Schowalter Electronic Book Production Services: The Publisher's Network Macintosh™ is a licensed trademark of Apple Computer Corporation. Copyright© 1986 by John Wiley & Sons, Inc. All rights reserved. Published simultaneously in Canada. Reproduction or translation of any part of this work beyond that permitted by Section 107or108 of the 1976 United States Copyright Act without the permission of the copyright owner is unlawful. Requests for permission or further infor- mation should be addressed to the Permissions Department, John Wiley & Sons, Inc. Library of Congress Cataloging-in-Publication Data Crandall, Richard E., 1947- Scientific programming with Macintosh PASCAL. 1. Macintosh (Computer)-Programming. 2. PASCAL (Computer program language) 3. Science-Data processing. I. Colgrove, Marianne M. II. Title. QA76.8.M3C73 1986 005.2'65 85-19083 ISBN 0-471-82176-4 Printed in the United States of America 86 87 10 9 8 7 6 5 4 3 2 1

Reading notes: Printed number '005.2'65' in cataloging data may be a garbled classification number

Printed dates
1986 · 1976 · 1947 · 85-19083 · 86 87
Languages
English
PDF page 6

Contents Preface Chapter 1 Chapter2 Chapter3 Introduction Why Macintosh Pascal? 1 Selected Bibliography of Pascal Texts and Reference Books 8 Programming Macintosh Devices Description of Devices 9 The Screen 10 The Keyboard 16 TheMouse 17 The Sound Generator 18 The Printer 19 TheDisk 20 The Timers 22 Using Devices Efficiently 25 Numerical Programs Sequences of Integers 45 Limits and Sums 51 Differential Calculus 56 Newton's Method 59 Integral Calculus 61 Complex Numbers, Vectors and Matrices 62 Linear Equations 67 vii 1 9 45 v

Reading notes: Page number columns are detached from entries, so pairings are uncertain.

Printed product names
Macintosh Pascal
Languages
English
PDF page 7

Scientific Programming with Macintosh Pascal

vi • Scientific Programming with Macintosh Pascal Chapter4 Chapters Chapter6 Chapter 7 Chapters Chapter9 Appendix A Index Graphics and Animation Real-valued Coordinates 98 Graphing of Functions 100 Graphic Solutions 103 Animation 104 Probability and Statistics Random Integers 134 Random Reals 136 Probability 138 Statistics 140 Three-Dimensional Graphics The Euler Angles 160 Three-Dimensional Graphs 162 Perspective 163 Dynamical Models Space-Time Models 181 Parametric Space Curves 182 Animation 184 Serial 1/0 and External Devices Basic Considerations for Serial 110 199 9600 Baud Terminal Emulator 200 Laboratory Serial Applications 201 Selected Scientific Applications Fourier Analysis 221 Advanced Mathematical Methods 224 Classroom Programs 228 Testing of Theories 229 Deep Calculation 231 98 134 160 181 199 221 259 277

Reading notes: Table of contents page numbers and chapter/section headings are mixed in reading order. 'Serial 1/0' appears with a possible OCR error for 'I/O' and 'Basic Considerations for Serial 110' may be a misreading of '1/0'.

Printed product names
Macintosh Pascal
Languages
English
PDF page 8

Preface Scientific Programming with Macintosh Pascal is intended for Macintosh users who are interested in using their machines to produce scientific results. By results we mean not only calculations but graphics, sound, and general input/ output. To this end the book includes extensive example programs and exercises to cover what we perceive are the most important basic aspects of scientific programming. Where possible, we incorporate graphics and animation tech- niques-certainly Macintosh specialties-to convey scientific principles. Users who enjoy computer modeling will find the example programs of · special interest, chiefly because of the unique origin of those examples. The programs and ideas found within grew out of experiences in the science class- rooms of Reed College, where the use of Pascal in courses dates back to 1978. In such settings emphasis is placed on ideas as opposed to programs, with the latter used to support the learning and research. Accordingly, this book is not a computer science book. It is a book of scientific ideas, and we have chosen tried and true ideas which we know to be interesting to science students. There is no better testing ground for examples and exercises than a class of sharp, motivated beginning programmers. In many cases we modified older programs to take advantage of what is best about the Macintosh, doing this in response to feedback from teachers and students. We are indebted to the many faculty and students who lent their fine hands to the testing and modification of the programming ideas presented in the book. Special acknowledgements are due to Richard Wood and Peter Shirley whose advanced programs we have used in later chapters. Other contributors are Neil Alexander, Zoe Mendell, Nie McPhee, Scott Gillespie, and Shep Doeleman. The book strategy was markedly improved through discussions with Professor Robert Reynolds who teaches some active, well-populated introductory Pascal laboratories. We appreciate also the helpful encouragement and support from our friends at THINK Technologies and Apple Computer. We could not have done the project Without the inestimable clerical talents of Rebecca Kilgore. Richard E. Crandall Marianne M. Colgrove Portland, Oregon February 1986 vii

Reading notes: Preface page with a hyphenated line break at 'tech-niques' and 'input/output' that may affect reading order Bullet mark '·' appears inline and may be an OCR artifact

Printed product names
Macintosh Pascal
Printed dates
1978 · February 1986
Languages
English
PDF page 9

1 Introduction THEME: This chapter provides an introduction to the philoso- phy and format of Scientific Programming with Macintosh Pascal. It discusses the prerequisites and reference materials recom- mended for effective use of the book as well as the suggested approach to learning scientific programming. GOALS: You will be able to delve into practice programs and exercises with an awareness of Macintosh Pascal's strengths and weaknesses. Each chapter is summarized so those readers who have specific programming projects in mind will be able to select the appropriate chapters for study. REFERENCE MATERIALS: Novice programmers and Mac- intosh users will probably want to study an introductory Pascal text, the Macintosh User Manual, and/or the Macintosh Pascal User's Guide. See the end of this chapter for selected references. Why Macintosh Pascal? Pascal was developed by Niklaus Wirth in 1971 to fill the need for a simple-to- learn, easily implemented programming language which could be used to teach elementary programming concepts. Pascal, like other high-level languages, pro- vides programmers, and those studying Pascal programming, with the tools to communicate specific, un-ambiguous instructions to the computer. According to Cooper & Clancy (Ohl Pascall, p. xvii), the two primary goals of Pascal were jand are): 1. To provide a teaching language that would bring out concepts common to all languages, while avoiding inconsistencies and unnecessary detail. 2. To define a truly standard language that would be cheap and easy to imple- ment on any computer. Judging by Pascal's current popularity, both in educational and research settings, these objectives have been, for the most part, achieved. 1

Reading notes: Garbled OCR in 'Cooper & Clancy (Ohl Pascall, p. xvii), the two primary goals of Pascal were jand are)' – possible misreading around 'were ... are' Heading-like text 'Introduction' may be a chapter title rather than a primary heading

Printed product names
Macintosh Pascal · Macintosh User Manual · Macintosh Pascal User's Guide
Printed dates
1971
Languages
English
PDF page 10

Scientific Programming with Macintosh Pascal

2 • Scientific Programming with Macintosh Pascal Macintosh Pascal, designed by THINK Technologies exclusively for the Apple Macintosh, serves to enhance Pascal's fundamental ease of use and educa- tional value. Much of the credit for this belongs to the Apple Macintosh itself: its innovative devices, visual interface and general ease of use provide a base that is consistent with Pascal's ideals. With the addition of Macintosh Pascal's inter- pretive environment and strong error-checking and debugging features, the result is an easy-to-use, high-level programming language with great educational utility. Macintosh Pascal should not, however, be reserved for the classroom setting only. Its potential value as a tool for the sciences cannot be overlooked. Indeed, many of the special features of the Macintosh and Macintosh Pascal that make it a valuable teaching medium also make it a viable scientific tool. This book demonstrates many scientific problems for which the speed of solution is not the primary requirement: for example, a graphics display of a scientific model that is to be drawn on the screen. This is especially true when factoring the time needed to design and edit the required algorithms into a project's total development time. After just a little experience with the self-checking Macintosh Pascal Edit win- dow, one saves valuable time at refining and modifying the overall project. An extreme example of these considerations is the spectacular ray-tracing demon- stration by Peter Shirley, discussed in Chapter 9 as program Scene. Mr. Shirley was a student of one of the authors (REC) at the time the program was written. Though one must wait hours (literally) for the final graphics, it is a fact that Shirley wrote the program in one or two days. When he ran the first tests, he would simply do something else (besides programming) for the long waiting period, coming back eventually to view the Macintosh screen. Thus the Macin- tosh Pascal interpreter, although very slow in execution compared with com- piled systems, did not take away an undue portion of his personal time. The simple realization that his program was very fast in the writing lends support to the proficiency of the Macintosh Pascal approach for many problems of science. It is for users who can benefit from the advantages of the interpretive environment that Scientific Programming with Macintosh Pascal was designed. The dedicated learner who is willing to work through the sample programs and exercises will not only emerge with a strong understanding of basic scientific programming concepts, but should also be able to develop applications with considerable practical utility. In addition, the serious reader should be able to develop the problem-solving strategies that enable op.e to approach future pro- gramming problems creatively and elegantly. Before embarking on Scientific Programming, the reader should be familiar with the Macintosh visual interface and basic operations such as cutting, pasting, and text editing with mouse-oriented editors. If you have not previously used a Macintosh, refer to the Macintosh owner's guide for details on basic techniques. In addition, you should have a working knowledge of the fundamentals of the Pascal language. This book is not intended to teach you Pascal, rather, it is meant to help you expand the range of problems to which you can apply your program-

Reading notes: Possible OCR error: 'op.e' in text, likely 'you'

Printed product names
Macintosh Pascal · Apple Macintosh · Macintosh
Languages
English
PDF page 11

Introduction • 3 ming skills. Familiarity with the Macintosh Pascal programming environment- using the Observe window to debug a program, for example-is desirable, though not required. If you need additional preparation in any of the above areas, check the selected bibliography at the end of this book for appropriate texts and reference materials. The best way to learn the techniques discussed in this book is to sit down at a Macintosh and practice programming: work through the exercises at the end of each chapter; experiment with program changes and see what happens. This is not to say, however, that you should abandon paper and pencil in favor of long hours in front of a computer. It can be invaluable to draft a flow chart or a simple sketch of program logic before using the computer. In this way, frustrating bugs can often be anticipated or avoided altogether. You will undoubtedly develop a balance of paper and computer work time that most suits your particular needs. A combination of these methods will promote more efficient learning and pro- gramming than the exclusive use of either method. In addition to working with the chapter exercises, you should devise rela- tively large-scale projects to work on. Projects will help you develop problem- solving strategies as they involve many levels of difficulty. Solutions for each subproblem must fit together into a unified program. Devising your own project also insures that it will incorporate your particular area of interest and will more likely produce an application of personal utility. Lastly, a carefully defined project will have a very clear outcome, making it painfully obvious when a program doesn't run as intended. Working on such large-scale tasks will force you to look at the 'big picture' of program strategy and concept flow. The included exercises, on the other hand, provide detailed glimpses of specific commands and their results. Thus, projects and exercises should be used to complement each other. Any programming language has limitations and, therefore, trade-offs must be made. Any programmer, before embarking on a large scientific project, should be aware of the strengths and weaknesses of Macintosh Pascal. As an interpreted language, Macintosh Pascal provides reliable error-checking and feedback. As a result, program speed is sacrificed. Another trade-off arises from the use of specialized Mac features such as the mouse and high-resolution QuickDraw graphics routines. These are the very capabilities that make Macin- tosh Pascal unique; however, they can reduce the portability (to other machines or systems) of a given program. The user should also keep in mind the memory limitations of the 128K Macintosh: Macintosh programs are limited to approx- imately 33K in size on a 128K machine, making it most suited for medium to small applications. You can select 'About Macintosh Pascal' from the Apple Menu to see what the memory situation is for any program about to be run. Procedural libraries (listed in Appendix A) are used extensively in the book. There are a number of reasons for this emphasis on generalized libraries. First, such libraries help you maintain programmatical modularity and consistency. Second, because the libraries are grouped according to general concepts (e.g.,

Reading notes: Source text is a book introduction and is truncated mid-sentence at the end; no advertised products or prices appear.

Printed product names
Macintosh Pascal · Macintosh · Apple Menu
Languages
English