Jose m garrido introduction to computational modeling using c and open source tools - Pdf 11


INTRODUCTION TO
COMPUTATIONAL
MODELING USING C AND
OPEN-SOURCE TOOLS
José M. Garrido
Kennesaw State University
Kennesaw Georgia, USA
K22074_FM.indd 1 10/4/13 11:37 AM
Chapman & Hall/CRC
Computational Science Series
PUBLISHED TITLES
SERIES EDITOR
Horst Simon
Deputy Director
Lawrence Berkeley National Laboratory
Berkeley, California, U.S.A.
COMBINATORIAL SCIENTIFIC COMPUTING
Edited by Uwe Naumann and Olaf Schenk
CONTEMPORARY HIGH PERFORMANCE COMPUTING: FROM PETASCALE
TOWARD EXASCALE
Edited by Jeffrey S. Vetter
DATA-INTENSIVE SCIENCE
Edited by Terence Critchlow and Kerstin Kleese van Dam
PETASCALE COMPUTING: ALGORITHMS AND APPLICATIONS
Edited by David A. Bader
FUNDAMENTALS OF MULTICORE SOFTWARE DEVELOPMENT
Edited by Victor Pankratius, Ali-Reza Adl-Tabatabai, and Walter Tichy
GRID COMPUTING: TECHNIQUES AND APPLICATIONS
Barry Wilkinson
HIGH PERFORMANCE COMPUTING: PROGRAMMING AND APPLICATIONS

SCIENTIFIC DATA MANAGEMENT: CHALLENGES, TECHNOLOGY, AND DEPLOYMENT
Edited by Arie Shoshani and Doron Rotem
PUBLISHED TITLES CONTINUED
K22074_FM.indd 3 10/4/13 11:37 AM
MATLAB® and Simulink® are trademarks of The MathWorks, Inc. and are used with permission. The MathWorks
does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion of MATLAB® and
Simulink® software or related products does not constitute endorsement or sponsorship by The MathWorks of a
particular pedagogical approach or particular use of the MATLAB® and Simulink® software.
Original art “Aztec Calendar” by Victor H. Verde.
Photograph and graphic design by Tino Garrido-Licha.
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
© 2014 by Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, an Informa business
No claim to original U.S. Government works
Version Date: 20131028
International Standard Book Number-13: 978-1-4822-1679-0 (eBook - PDF)
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been
made to publish reliable data and information, but the author and publisher cannot assume responsibility for the
validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the
copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to
publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let
us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted,
or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, includ-
ing photocopying, microfilming, and recording, or in any information storage or retrieval system, without written
permission from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com

1.9.3 Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.9.4 Compiling and Execution of Java Programs . . . . . . . . . 13
1.9.5 Compiling and Executing C Programs . . . . . . . . . . . . 14
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Chapter 2 Programs 17
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2 Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3 Data Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.1 Name of Data Items . . . . . . . . . . . . . . . . . . . . . 18
2.3.2 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3.3 Data Declarations in C . . . . . . . . . . . . . . . . . . . . 19
v
vi
2.4 Structure of a C Program . . . . . . . . . . . . . . . . . . . . . . . 20
2.5 Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.6 Simple Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.6.1 Function Definitions . . . . . . . . . . . . . . . . . . . . . 22
2.6.2 Function Calls . . . . . . . . . . . . . . . . . . . . . . . . 23
2.7 A Simple C Program . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.8 A Simple Problem: Temperature Conversion . . . . . . . . . . . . 25
2.8.1 Mathematical Model . . . . . . . . . . . . . . . . . . . . . 25
2.8.2 Computational Model . . . . . . . . . . . . . . . . . . . . 26
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Chapter 3 Modular Decomposition: Functions 29
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.2 Modular Decomposition . . . . . . . . . . . . . . . . . . . . . . . 29
3.3 Defining Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.4 Calling Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Chapter 5 Algorithms and Programs 57
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.2 Problem Solving . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.3 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.4 Algorithm Description . . . . . . . . . . . . . . . . . . . . . . . . 58
5.5 Design Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.5.1 Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.5.2 Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.5.3 Repetition . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.6 Implementing Algorithms . . . . . . . . . . . . . . . . . . . . . . 62
5.6.1 Assignment and Arithmetic Expressions . . . . . . . . . . . 63
5.6.2 Simple Numeric Computations . . . . . . . . . . . . . . . . 63
5.6.3 Simple Input/Output . . . . . . . . . . . . . . . . . . . . . 65
5.7 Computing Area and Circumference . . . . . . . . . . . . . . . . . 67
5.7.1 Specification . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.7.2 Algorithm with the Mathematical Model . . . . . . . . . . 67
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Chapter 6 Selection 71
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.2 Selection Structure . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.2.1 Selection Structure with Flowcharts . . . . . . . . . . . . . 71
6.2.2 Selection with Pseudo-Code . . . . . . . . . . . . . . . . . 72
6.2.3 Implementing Selection with the C Language . . . . . . . . 73
6.2.4 Conditional Expressions . . . . . . . . . . . . . . . . . . . 73
6.2.5 Example with Selection . . . . . . . . . . . . . . . . . . . 74
6.3 A Computational Model with Selection . . . . . . . . . . . . . . . 75
6.3.1 Analysis and Mathematical Model . . . . . . . . . . . . . . 75

8.2.2 Declaring Arrays in C . . . . . . . . . . . . . . . . . . . . 100
8.3 Operations on Arrays . . . . . . . . . . . . . . . . . . . . . . . . . 101
8.3.1 Manipulating Array Elements in Pseudo-Code . . . . . . . 101
8.3.2 Manipulating Elements of an Array in C . . . . . . . . . . . 101
8.4 Arrays as Arguments . . . . . . . . . . . . . . . . . . . . . . . . . 102
8.5 A Simple Application with Arrays . . . . . . . . . . . . . . . . . . 104
8.6 Arithmetic Operations with Vectors . . . . . . . . . . . . . . . . . 106
8.7 Multi-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . 107
8.7.1 Multi-Dimensional Arrays in Pseudo-Code . . . . . . . . . 108
8.7.2 Multi-Dimensional Arrays in C . . . . . . . . . . . . . . . 108
8.7.3 Passing Multi-Dimensional Arrays . . . . . . . . . . . . . . 109
8.8 Applications Using Arrays . . . . . . . . . . . . . . . . . . . . . . 110
8.8.1 Problems with Simple Array Manipulation . . . . . . . . . 110
8.8.1.1 Average Value in an Array . . . . . . . . . . . . . 110
8.8.1.2 Maximum Value in an Array . . . . . . . . . . . 112
8.8.2 Searching . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
8.8.2.1 Linear Search . . . . . . . . . . . . . . . . . . . 113
8.8.2.2 Binary Search . . . . . . . . . . . . . . . . . . . 114
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
ix
Chapter 9 Pointers 117
9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
9.2 Pointer Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . 117
9.3 Pointers with C . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
9.4 Dereferencing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
9.5 Converting Pointer Types . . . . . . . . . . . . . . . . . . . . . . . 119
9.6 Reference Parameters . . . . . . . . . . . . . . . . . . . . . . . . 119
9.7 Pointers with Value NULL . . . . . . . . . . . . . . . . . . . . . . 120
9.8 Arrays as Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . 122

11.5 Using the String Functions . . . . . . . . . . . . . . . . . . . . . . 156
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
x
Chapter 12 Computational Models with Arithmetic Growth 161
12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
12.2 Mathematical Modeling . . . . . . . . . . . . . . . . . . . . . . . 161
12.2.1 Difference Equations . . . . . . . . . . . . . . . . . . . . . 162
12.2.2 Functional Equations . . . . . . . . . . . . . . . . . . . . . 163
12.3 Models with Arithmetic Growth . . . . . . . . . . . . . . . . . . . 164
12.4 Using the C Programming Language . . . . . . . . . . . . . . . . 164
12.5 Producing the Charts of the Model . . . . . . . . . . . . . . . . . . 167
12.6 Validation of a Model . . . . . . . . . . . . . . . . . . . . . . . . 168
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Chapter 13 Computational Models with Quadratic Growth 171
13.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
13.2 Differences of the Data . . . . . . . . . . . . . . . . . . . . . . . . 171
13.3 Difference Equations . . . . . . . . . . . . . . . . . . . . . . . . . 174
13.4 Functional Equations . . . . . . . . . . . . . . . . . . . . . . . . . 175
13.5 Examples of Quadratic Models . . . . . . . . . . . . . . . . . . . 175
13.5.1 Growth of Number of Patients . . . . . . . . . . . . . . . . 175
13.5.2 Growth of Computer Networks . . . . . . . . . . . . . . . . 176
13.5.3 Models with Sums of Arithmetic Growth . . . . . . . . . . 178
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Chapter 14 Models with Geometric Growth 183
14.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
14.2 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
14.2.1 Increasing Data . . . . . . . . . . . . . . . . . . . . . . . . 184

17.2.3 Multiplication of a Vector and a Scalar . . . . . . . . . . . . 220
17.2.4 Dot Product of Two Vectors . . . . . . . . . . . . . . . . . 221
17.2.5 Length (Norm) of a Vector . . . . . . . . . . . . . . . . . . 221
17.3 Vector Properties and Characteristics . . . . . . . . . . . . . . . . 222
17.3.1 Orthogonal Vectors . . . . . . . . . . . . . . . . . . . . . . 222
17.3.2 Linear Dependence . . . . . . . . . . . . . . . . . . . . . . 222
17.4 Implementation of Vectors in C and the GSL . . . . . . . . . . . . 222
17.5 Simple Vector Operations . . . . . . . . . . . . . . . . . . . . . . 224
17.5.1 Arithmetic Operations . . . . . . . . . . . . . . . . . . . . 224
17.5.2 Additional Vector Functions . . . . . . . . . . . . . . . . . 225
17.5.3 Vector Views . . . . . . . . . . . . . . . . . . . . . . . . . 228
17.5.4 Complex Vectors . . . . . . . . . . . . . . . . . . . . . . . 229
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Chapter 18 Matrices and Sets of Linear Equations 235
18.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
18.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
18.2.1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . 235
18.2.2 Arithmetic Operations . . . . . . . . . . . . . . . . . . . . 236
18.2.3 Matrix Manipulation in C and the GSL . . . . . . . . . . . 240
18.3 Simple Matrix Operations . . . . . . . . . . . . . . . . . . . . . . 242
18.3.1 Arithmetic Operations . . . . . . . . . . . . . . . . . . . . 242
18.3.2 Additional Matrix Functions . . . . . . . . . . . . . . . . . 245
18.3.3 GSL Matrix Views . . . . . . . . . . . . . . . . . . . . . . 250
18.4 Solving Systems of Linear Equations . . . . . . . . . . . . . . . . 253
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
xii
Chapter 19 Introduction to Dynamical Systems 261
19.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

20.2.2 Case Study 2 . . . . . . . . . . . . . . . . . . . . . . . . . 295
20.2.2.1 Understanding the Problem . . . . . . . . . . . . 295
20.2.2.2 Mathematical Formulation . . . . . . . . . . . . 296
20.2.3 Case Study 3 . . . . . . . . . . . . . . . . . . . . . . . . . 296
20.2.3.1 Understanding the Problem . . . . . . . . . . . . 296
20.2.3.2 Mathematical Formulation . . . . . . . . . . . . 296
20.2.4 Case Study 4 . . . . . . . . . . . . . . . . . . . . . . . . . 297
20.2.4.1 Understanding the Problem . . . . . . . . . . . . 297
20.2.4.2 Mathematical Formulation . . . . . . . . . . . . 297
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
xiii
Chapter 21 Solving Linear Optimization Problems 301
21.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
21.2 General Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
21.3 Foundations of the Algorithm . . . . . . . . . . . . . . . . . . . . 302
21.3.1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . 302
21.3.2 Problem Formulation in Standard Form . . . . . . . . . . . 302
21.3.3 Generalized Standard Form . . . . . . . . . . . . . . . . . 304
21.3.4 Additional Definitions . . . . . . . . . . . . . . . . . . . . 304
21.4 Simplex Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . 305
21.4.1 General Description of the Simplex Algorithm . . . . . . . 305
21.4.2 Detailed Description of the Simplex Algorithm . . . . . . . 305
21.4.3 Degeneracy and Convergence . . . . . . . . . . . . . . . . 307
21.4.4 Two-Phase Method . . . . . . . . . . . . . . . . . . . . . . 307
21.5 Software Implementations . . . . . . . . . . . . . . . . . . . . . . 307
21.5.1 Solution with LP
solve . . . . . . . . . . . . . . . . . . . . 307
21.5.1.1 Example 1 with LP solve . . . . . . . . . . . . . 308
21.5.1.2 Example 2 with LP solve . . . . . . . . . . . . . 309

23.2 Model of a Transportation Problem . . . . . . . . . . . . . . . . . 339
23.3 Transportation Case Studies . . . . . . . . . . . . . . . . . . . . . 341
23.3.1 Transport Case Study 1 . . . . . . . . . . . . . . . . . . . . 341
23.3.2 Unbalanced Problem: Case Study 2 . . . . . . . . . . . . . 343
23.3.3 Unbalanced Problem: Case Study 3 . . . . . . . . . . . . . 346
23.4 Transshipment Models . . . . . . . . . . . . . . . . . . . . . . . . 348
23.4.1 General Form of Model . . . . . . . . . . . . . . . . . . . 349
23.4.2 Transshipment Problem: Case Study 4 . . . . . . . . . . . . 349
23.5 Assignment Problems . . . . . . . . . . . . . . . . . . . . . . . . 352
23.5.1 General Form of Model . . . . . . . . . . . . . . . . . . . 352
23.5.2 Assignment Problem: Case Study 5 . . . . . . . . . . . . . 352
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Chapter 24 Network Models 357
24.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
24.2 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
24.3 Shortest Path Problem . . . . . . . . . . . . . . . . . . . . . . . . 357
24.4 Shortest Path Problem: Case Study 1 . . . . . . . . . . . . . . . . 358
24.5 Maximum Flow Problems . . . . . . . . . . . . . . . . . . . . . . 361
24.6 Critical Path Method . . . . . . . . . . . . . . . . . . . . . . . . . 364
24.6.1 Using Linear Optimization . . . . . . . . . . . . . . . . . . 365
24.6.2 Critical Path Method: Case Study 2 . . . . . . . . . . . . . 365
24.6.3 Reducing the Time to Complete a Project . . . . . . . . . . 367
24.6.4 Case Study 3 . . . . . . . . . . . . . . . . . . . . . . . . . 367
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
Chapter 25 Integer Linear Optimization Models 373
25.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
25.2 Modeling with Integer Variables . . . . . . . . . . . . . . . . . . . 373
25.3 Applications of Integer Linear Optimization . . . . . . . . . . . . . 374

B.6 Shell Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
B.6.1 The pwd Command . . . . . . . . . . . . . . . . . . . . . 412
B.6.2 The more Command . . . . . . . . . . . . . . . . . . . . . 412
B.6.3 The script Command . . . . . . . . . . . . . . . . . . . 412
B.6.4 The exit Command . . . . . . . . . . . . . . . . . . . . . 412
B.7 Text Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
B.8 File Access Permissions . . . . . . . . . . . . . . . . . . . . . . . 413
B.9 Chaining Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
B.10 Commands for Process Control . . . . . . . . . . . . . . . . . . . 415
B.11 Foreground and Background Processes . . . . . . . . . . . . . . . 416
B.12 Script Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
B.12.1 Comments in Scripts . . . . . . . . . . . . . . . . . . . . . 417
B.12.2 Positional Parameters . . . . . . . . . . . . . . . . . . . . . 417
B.12.3 Command Substitution . . . . . . . . . . . . . . . . . . . . 417
B.12.4 The test Command . . . . . . . . . . . . . . . . . . . . . 417
B.12.5 The if with the test Commands . . . . . . . . . . . . . . 418
B.12.6 The set Command . . . . . . . . . . . . . . . . . . . . . 420
B.12.7 Repetition . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
B.13 Searching Data in Files . . . . . . . . . . . . . . . . . . . . . . . . 423
B.14 Evaluating Expressions . . . . . . . . . . . . . . . . . . . . . . . . 425
Bibliography 427
Index 431
This page intentionally left blankThis page intentionally left blank
List of Figures
1.1 Computational science as an integration of several disciplines. . . . 4
1.2 Development of computational models. . . . . . . . . . . . . . . . 4
1.3 Model development and abstract levels. . . . . . . . . . . . . . . . 6
1.4 Continuous model. . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Discrete changes of number of cars in the queue. . . . . . . . . . . 9
1.6 The waterfall model. . . . . . . . . . . . . . . . . . . . . . . . . . 12

8.1 A simple array. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
8.2 A two-dimensional array. . . . . . . . . . . . . . . . . . . . . . . 100
8.3 Plot of the values of the vertical position with time. . . . . . . . . . 106
9.1 Pointer variable xptr pointing to variable x. . . . . . . . . . . . . . 118
10.1 Structure of a node. . . . . . . . . . . . . . . . . . . . . . . . . . 132
10.2 A simple linked list. . . . . . . . . . . . . . . . . . . . . . . . . . 132
10.3 A new node inserted in the front of a linked list. . . . . . . . . . . 136
10.4 A new node inserted after node 2. . . . . . . . . . . . . . . . . . . 136
10.5 A linked list with two ends. . . . . . . . . . . . . . . . . . . . . . 142
10.6 A linked list with two links per node. . . . . . . . . . . . . . . . . 143
10.7 A stack as a dynamic data structure. . . . . . . . . . . . . . . . . . 145
10.8 A queue as a dynamic data structure. . . . . . . . . . . . . . . . . 148
11.1 A C string. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
12.1 Given and computed values of monthly price of electric energy. . . 167
13.1 Plot of data in the sequence. . . . . . . . . . . . . . . . . . . . . . 172
13.2 Plot of first differences . . . . . . . . . . . . . . . . . . . . . . . . 173
13.3 Number of patients for 1995–2002. . . . . . . . . . . . . . . . . . 176
13.4 Number of links to connect n computers . . . . . . . . . . . . . . 178
14.1 Data with geometric growth. . . . . . . . . . . . . . . . . . . . . . 184
14.2 Data decreasing with geometric growth. . . . . . . . . . . . . . . . 185
14.3 Population of a small town for 1995–2003. . . . . . . . . . . . . . 187
14.4 Impurities in water (parts/gallon). . . . . . . . . . . . . . . . . . . 189
15.1 Graph of the equation y = 2x
3
−3x
2
−36x + 14. . . . . . . . . . . 198
15.2 Graph of the equation y = 3x
5
−2. . . . . . . . . . . . . . . . . . 199

4.1 Values of height and vertical velocity. . . . . . . . . . . . . . . . . 51
12.1 Average price of electricity (cents per kW-h) in 2010. . . . . . . . 163
13.1 Number of patients for years 1995–2002. . . . . . . . . . . . . . . 176
13.2 Number of cable installations for years 1995–2002. . . . . . . . . 178
13.3 Temperature changes in 12-hour period. . . . . . . . . . . . . . . . 180
14.1 Population of a small town during 1995–2003 (in thousands). . . . 185
16.1 Temperature changes in 12-hour period. . . . . . . . . . . . . . . . 216
16.2 Number of patients for years 1995–2002. . . . . . . . . . . . . . . 217
24.1 Airline routes from Chicago to Rio. . . . . . . . . . . . . . . . . . 361
24.2 Project data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
24.3 Project additional cost. . . . . . . . . . . . . . . . . . . . . . . . . 368
25.1 Items for Knapsack. . . . . . . . . . . . . . . . . . . . . . . . . . 376
B.1 System directories. . . . . . . . . . . . . . . . . . . . . . . . . . . 399
B.2 I/O redirection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
B.3 Test command operators for expressions with numbers. . . . . . . 418
B.4 Test command operators for expressions with strings. . . . . . . . 418
B.5 Test command operators for expressions with files. . . . . . . . . . 419
xxi
This page intentionally left blankThis page intentionally left blank
Preface
A computational model is a computer implementation of the solution to a (scien-
tific) problem for which a mathematical representation has been formulated. These
models are applied in various areas of science and engineering to solve large-scale
and complex scientific problems. Developing a computational model involves for-
mulating the mathematical representation and implementing it by applying computer
science concepts, principles and methods.
Computational modeling focuses on reasoning about problems using compu-
tational thinking and multidisciplinary/interdisciplinary computing for developing
computational models to solve complex problems. It is the foundation component
of computational science, which is an emerging discipline that includes concepts,

source versatile tool for the visualization of the data computed. Other software tools
used in the book are GLPK, LP Solve and CodeBlocks.
The material in this book is aimed at intermediate to advanced undergraduate
science (and engineering) students. However, the vision in the book is to promote
and introduce the principles of computational modeling as early as possible in the
undergraduate curricula and to introduce the approaches of multidisciplinary and
interdisciplinary computing.
This book provides a foundation for more advanced courses in scientific comput-
ing, including parallel computing using MPI, grid computing and other techniques
used in high-performance computing.
The material in the book is presented in five parts. The first part is an overview of
problem solving, introductory concepts and principles of computational models, and
their development. This part introduces the basic modeling and techniques for de-
signing and implementing problem solutions, independent of software and hardware
tools.
The second part presents an overview of programming principles with the C pro-
gramming language. The relevant topics are basic programming concepts, data defi-
nitions, programming structures with flowcharts and pseudo-code, solving problems
and algorithms, arrays, pointers, basic data structures, and compiling, linking, and
executing programs on Linux.
The third part applies programming principles and techniques to implement the
basic computational models. It gradually introduces numerical methods and mathe-
matical modeling principles. Simple case studies of problems that apply mathemat-
ical models are presented. Case studies are of simple linear, quadratic, geometric,
polynomial, and linear systems using GSL. Computational models that use polyno-
mial evaluation, computing roots of polynomials, interpolation, regression, and sys-
tems of linear equations are discussed. Examples and case studies demonstrate the
computation and visualization of data produced by computational models.
The fourth part presents an overview of more advanced concepts needed for mod-
eling dynamical systems. Most of the models are formulated with ordinary differen-


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status