There can be little argument that computation has become an essential element in all areas of physics, be it via simulation, symbolic manipulations, data manipulations, equipment interfacing, or something with which we are not yet familiar. Nevertheless, even though the style of teaching and organization of subjects being taught by physics departments has changed in recent times, the actual content of the courses has been slow to incorporate the new-found importance of computation. Yes, there are now speciality courses and many textbooks in Computational Physics, but that is not the same thing as incorporating computation into the very heart of a modern physics curriculum so that the physics being taught today more closely resembles the physics being done today. Not only will such integration provide valuable professional skills to students, but it will also help keep physics alive by permitting new areas to be studied and old problems to be solved.
This series is intended to provide undergraduate and graduate level textbooks for a modern physics curriculum in which computation is incorporated within the traditional subjects of physics, or in which there are new, multidisciplinary subjects in which physics and computation are combined as a “computational science.” The level of presentation will allow for their use as primary or secondary textbooks for courses that wish to emphasize the importance of numerical methods and computational tools in science. They will offer essential foundational materials for students and instructors in the physical sciences as well as academic and industry professionals in physics, engineering, computer science, applied math, and biology.
Titles in the series are targeted to specific disciplines that currently lack a textbook with a computational physics approach. Among these subject areas are condensed matter physics, materials science, particle physics, astrophysics, mathematical methods of computational physics, quantum mechanics, plasma physics, fluid dynamics, statistical physics, optics, biophysics, electricity and magnetism, gravity, cosmology, and high-performance computing in physics. We aim for a presentation that is concise and practical, often including solved problems and examples. The books are meant for teaching, although researchers may find them useful as well. In select cases, we have allowed more advanced, edited works to be included when they share the spirit of the series—to contribute to wider application of computational tools in the classroom as well as research settings.
Although the series editors had been all-too-willing to express the need for change in the physics curriculum, the actual idea for this series came from the series manager, Luna Han of Taylor & Francis Publishers. We wish to thank her sincerely for that, as well as for encouragement and direction throughout the project.
This book is devoted to the general field of numerical programming, with emphasis on methods specific to computational physics and engineering. While tremendous advances of computer performances have been achieved in recent years, numerical methods still remain virtually inexhaustible resources for extending the range of challenging real-life problems made tractable. Along these lines, the book sets as its primordial goal to contribute to fostering interest in numerical programming by making computations accessible and appealing to broader categories of scientists and engineers. I have written this book for advanced undergraduate and graduate students in natural sciences and engineering, with the aim of being suited as curriculum material for a oneor two-semester course in numerical programming based on Python or C/C++. The book may also be used for independent study or as a reference material beyond academic studies. It may be useful, for instance, as an introductory text for researchers preparing to engage in scientific computing, or engineers needing effective numerical tools for applicative calculations.
Introduction to Numerical Programming free PDF
I have placed emphasis on the rigorous, yet accessible presentation of the fundamental numerical methods, which are complemented with implementations and applications, highlighting specific numerical behavior and often featuring graphical output. Although the material requires basic knowledge of calculus, linear algebra, and differential equations, it does not assume previous acquaintance with numerical techniques, leading the reader all the way from elementary algorithms to elaborate methods of relevance for modern numerical programming. Notably, there is a steady increase of complexity of the methods which are dealt with, both within each chapter and along the sequence of chapters.
In essence, the book aims at assisting the reader in developing their capacity of algorithmic reasoning, a specific coding dexterity, and an efficient scientific programming style, which are essential prerequisites for subsequent involvement in comprehensive programming projects.
Relation to reference works. The literature abounds in excellent books on numerical programming. To mention just two works that have set milestones in the field, the book makes frequent reference to Numerical Analysis by R.L. Burden and J.D. Faires, and to Numerical Recipes by W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery. Some reference texts excel in the rigorous presentation of the mathematical foundations and algorithms, yet with generic implementations and limited justifications of the concretely employed coding solutions. Other works highlight the subtleties and performance of concrete implementations, being mainly addressed to experienced users. The goal of this book is to bridge the two mentioned options, providing the reader with an adequate level of proficiency by following a route which develops a well-balanced combination of basic theoretical knowledge, as well as code design and efficiency analysis skills. Along the way, constant emphasis is laid on the fact that good programming is neither barely a mechanistic translation of mathematical formulas into a programming language, nor should effective implementations be complicated by principle.
In all respects, the book follows as a guiding principle the “beauty of simplicity” with a view to achieving effectiveness and long-lasting usability of numerical applications. As a distinctive feature, the book also attaches particular importance to graphical representations, as a means of synthetic assessment of numerical behavior, the material deliberately being highly visual and brimming with graphs.
Programming languages. In terms of programming languages, the book relies on standard Python (version 3.3) and ANSI C/C++, not making use of any additional packages. On the one hand, the choice is motivated by their modern “minimalism,” which enables the systematic presentation of programming concepts with relatively simple means, and on the other, by their ubiquity, which ensures the crossplatform portability of the applications, as well as the potential mobility of the users to other fields of applied programming.
Introduction to Numerical Programming PDF download
As for Python, it proves its virtues ever more increasingly, not only as an easy-to-use teaching language, but also in high-performance computing for creating complementary scripts and graphical user interfaces in conjunction with compiled languages, or for building stand-alone applications in various fields of present-day science and technology. With this in mind, the book addresses both the effectiveness of the compiled C/C++ code and the ease-of-use and portable graphical features of the interpreter-based Python applications.
Starting from the fact that code indentation is compulsory in Python, but optional in C/C++ (being merely a means of enhancing code readability), throughout the book we employ a unified code formatting style for Python and C/C++, implying an indentation size of three spaces for marking consecutive subordination levels.
Numerical methods. The numerical methods are presented in detail, although avoiding an excess of purely mathematical aspects. The implementations are designed so as to highlight the specificity of scientific programming, and, for the sake of creating a consistent programming style, they assume a compromise between clarity and performance. In certain cases, without sacrificing the execution speed, less efficient memory usage but more elegant and illustrative implementations are preferred.
The routines are richly commented in order to clarify the role of the various parameters, variables, and code sequences. The comments on individual code lines are generally right aligned in order not to disperse the executable sequences and to save on source file size.
Addition of delicate algorithmic elements is carried out in a gradual manner, through successive versions of the routines of increasing complexity. The routines are complemented with numerical examples, designed to elucidate the data input/output and to highlight specific numerical behavior of the solutions.
The material also emphasizes the cross-disciplinary usability of numerical methods originally developed for specific fields of computational physics or engineering. As a concrete example, the Verlet propagator, which is a well-established method for solving equations of motion in molecular dynamics simulations, can additionally be applied successfully to study the motion of celestial systems. The text also points repeatedly to the fact that mastering numerical methods implies to a large extent the in-depth understanding and control of errors.
Python versions of the developed routines are listed separately in each chapter, alongside the relevant theoretical and algorithmic aspects, while C/C++ versions are listed jointly as header files in separate sections, generically titled “Implementations in C/C++.” In perfect symmetry, the Python routines are also grouped in modules corresponding to each of the treated chapters.
Introduction to Numerical Programming book 2021
In fact, the book brings forward two similar Python and C/C++ numerical libraries, numxlib.py and numxlib.h, which include the partial libraries developed in the separate chapters (see Appendix D for a description). Even though the applications illustrating the various numerical methods exposed in the book employ the partial numerical libraries (as, for instance, ode.py or ode.h is included for solving ordinary differential equations), the overall library numxlib can well be used in their place, and this is actually the recommended option, once the numerical methods presented in the book have been mastered.
Graphics. Bearing in mind that in modern research the amount of output data quite often exceeds the user’s capacity to analyze individual figures, as already mentioned, the book places importance on graphical representation methods, which are able to reveal global trends, otherwise difficult to extract from numeric sequences. The graphics is based on the remarkable capabilities of Python’s Tkinter package, not in the least taking advantage of its wide-ranging portability. In Chapter 3, the book puts forward a versatile Python graphics library, graphlib.py (see also Appendix E), which is used throughout the material to produce runtime graphics both from Python and C/C++. In particular, the C/C++ applications gain access to graphlib.py via a dedicated interface file, graphlib.h (see Appendix F).
The persistent use of graphical presentation methods is meant to stimulate the development of abilities for building large-scale scientific applications with graphical user interfaces.
Exercise problems. The applications in each chapter complementing theoretical aspects and implemented routines mainly address illustrative topics from undergraduate-level courses, such as Mechanics, Electricity, Optics, and Quantum Physics. More complex topics, involving concepts beyond the undergraduate curriculum, are typically presented in the final sections of the chapters, being mainly intended to highlight the full potential of the basic numerical methods and to provide instructors and researchers with additional material.
The input to the problems is deliberately kept simple, often merely as bare assignments to the problem parameters, in order to allow the reader to focus on the essential aspects. The hands-on style of presenting the material, with trial-and-error routes, with emphasis on advantages and pitfalls, encourages the reader to develop skills by experimenting.
Introduction to Numerical Programming: A Practical Guide for Scientists and Engineers Using Python and C/C++ (Series in Computational Physics)
As a rule, the C/C++ versions of the programs are not included in the “Problems” section of the chapters. Instead, along with their Python counterparts, they are to be found as supplementary material on the book’s website. Also as a general rule, all the routines, libraries, and programs come in pairs of Python and C/C++ files having identical names and appropriate extensions.
Book structure. The book is divided into 13 chapters. Following this introduction, Chapter 1 deals with the main aspects of approximate numbers and propagation of associated errors. Without giving a systematic presentation of the Python and C languages, Chapter 2 reviews the language elements of interest to coding the numerical methods developed in later chapters. Chapter 3 is devoted to introducing elements of graphic functionality in Python and C/C++ applications. In Chapter 4 basic sorting and indexing methods are presented.
Chapter 5 describes prototypical techniques of function evaluation (in particular, for special functions). Chapter 6 describes methods for solving algebraic and transcendental equations, while Chapter 7 is devoted to describing the most important methods for solving systems of linear equations. Chapter 8 deals with eigenvalue problems, in particular, for symmetric matrices. Chapter 9 is concerned with approximating tabulated functions, specifically by interpolation (including by spline functions) and regression (including nonlinear regression).
Chapter 10 describes methods of integrating oneand multi-dimensional functions by classical and Gaussian quadratures, while Chapter 11 is devoted to Monte Carlo integration techniques and generation of random variables with various distributions. In Chapter 12 methods for solving ordinary differential equations are presented, ranging from Runge–Kutta to Numerov’s method, and Chapter 13 discusses the most important discretization methods for elliptic, parabolic, and hyperbolic partial differential equations, familiarizing the reader with the stability analysis.
Supplementary material and the book’s website. The book is complemented with material provided on the book’s website.