The second edition of my textbook “Numerical Methods in Physics with Python” was published by Cambridge University Press in July 2023. Already since its first edition, the book’s focus was pretty clear: foundational numerical methods were derived from scratch, implemented in the Python programming language, and applied to challenging physics projects. That first edition was published less than three years ago, so it may be worthwhile to see how the updates came about (and thereby also explain why a second edition was warranted). Over the last several semesters, I have been fortunate enough to teach both undergraduate and graduate courses on computational physics out of my textbook (repeatedly); thus,
“the changes to the book between editions have been directly driven by what worked in the classroom (and what didn’t)”.
The undergraduate course (renditions) revolved around a subset of the numerical methods/codes in the first edition, but I found that some further topics needed to be introduced, most notably on linear algebra (singular-value decomposition), optimization (golden-section search), and partial differential equations (finite-difference approaches). Perhaps even more crucially, given the heavy emphasis on math and programming in the undergrad version of the course, some students were left wanting more of a physics bent: to address that need, I created a large number of problems on physical applications both on standard themes and on topics that I have not encountered in other computational-physics textbooks (e.g., the BCS theory of superfluidity, the Heisenberg uncertainty relation, or the stability of the outer solar system). In each case, the idea was to complement the end-of-chapter (worked-out) Projects with (sometimes short, other times fairly extensive) problems showing how the numerical methods (and programming skills) developed in a given chapter can be put to use when studying physics. When introducing these new physical themes into the second edition, I sometimes found it natural to split them across chapters; to give but one example, the band gaps of solid-state physics are successively studied as a plotting, linear-algebra, root-finding, minimization, and integration problem.
The graduate course (incarnations) that I taught also necessitated new physics problems: perhaps unsurprisingly, these were closer to modern-day research (e.g., scalar self-interacting field theory, the gravitational three-body problem, or the optical Bloch equations). Given that the intended audience here was more advanced, I also worked out from scratch things that are usually taken for granted (e.g., the minimax property of Chebyshev polynomials or asymptotic normality) when not passed over in silence (e.g., the computation of complex eigenvalues or an iterative approach to the fast Fourier transform). Turning to the lectures: these typically focused on the most equation-heavy numerical methods from the first edition; I supplemented them with new material on many-dimensional derivative-free optimization as well as nonlinear regression. The latter led me to the hot topic of artificial neural networks (the power of which is exemplified by the accompanying plot). Speaking of regression, the single most important change in the second edition is a new section on statistical inference (which somehow manages to be both concise and lengthy): this starts out by recovering/justifying first-edition results (e.g., regarding the interpretation of the chi-squared statistic) before turning to the Bayesian approach, uncertainty bands, etc. While writing this new section I realized that the discussion of data analysis in many introductory (or not so introductory) textbooks is questionable, as summarized in this spin-off journal article.
A crucial aspect of the first edition was the inclusion of dozens of complete Python implementations of numerical methods or physical applications. The (six) new sections in the second edition have also led me to write six new codes, which are given at the companion website and discussed in gory detail in the main text. The fifteeneightyfour blog post I wrote when the first edition of the textbook came out (see What’s wrong with black boxes? ) goes over the motivation behind and significance of the codes. In the same spirit of working things out from scratch, the codes are further probed in the (140) new end-of-chapter problems. Speaking of which, typically computational-physics textbook authors either produce no solutions to the problems or provide solutions only to instructors teaching for-credit courses out of the textbook. I have followed the latter route, providing complete solutions of all programming problems to instructors; these are locked, since course instructors would not be able to assign them as homework problems otherwise. Even so, at the companion website I’m also providing a subset of the solutions to all readers, as a self-study resource.
In addition to the new sections, codes, problems, and solutions discussed above, while putting together the second edition I took the opportunity to read through the entire book multiple times and thoroughly tweak it, with a view to making the work more student-friendly. This ranged from introducing new footnotes or figures, to complete rewrites of first-edition sections, all the way to revamping the index. I have certainly enjoyed navigating this book’s wine-dark sea; perhaps you will, too.
Title: Numerical Methods in Physics with Python
Author: Alex Gezerlis
Latest Comments
Have your say!