migrating code to C via Cython is exempliﬁed in Appendix G,. Finally,
Appendix H deals with various more advanced technical topics.
Most of the examples and exercises in this book are quite short.
However, many of the exercises are related, and together they form larger
projects, for example on Fourier Series (3.15, 4.20, 4.21, 5.39, 5.40),
numerical integration (3.6, 3.7, 5.47, 5.48, A.12), Taylor series
(3.31, 5.30, 5.37, A.14, A.15, 7.23), piecewise constant functions
(3.23-3.27, 5.32, 5.45, 5.46, 7.19-7.21), inverse functions (E.17-E.20),
falling objects (E.8, E.9, E.38, E.39), oscillatory population growth
(A.19, A.21, A.22, A.23), epidemic disease modeling (E.41-E.48), op-
timization and ﬁnance (A.24, 8.39, 8.40), statistics and probability
(4.23, 4.24, 8.21, 8.22), hazard games (8.8-8.13), random walk and
statistical physics (8.30-8.37), noisy data analysis (8.41-8.43), numerical
methods (5.23-5.25, 7.8, 7.9, A.9, 7.22, 9.15-9.17, E.30-E.37), building a
calculus calculator (7.33, 9.18, 9.19), and creating a toolkit for simulating
vibrating engineering systems (E.50-E.55).
Chapters 1-9 together with Appendices A and E have from 2007formed
the core of an introductory ﬁrst semester bachelor course on scientiﬁc
programming at the University of Oslo (INF1100, 10 ECTS credits).
Changes from the third to the fourth edition. . Alargenumber of
the exercises have been reformulated and reorganized. Typically, longer
exercises are divided into subpoints a), b), c), etc., various type of help is
factored out in separate paragraphs marked withHint, and information
that puts the exercise into a broader context is placed at the end under
the heading Remarks. Quite some related exercises have been merged.
Another major change is the enforced focus on testing and veriﬁcation.
Already as soon as functions are introduced in Chapter 3, we start verify-
ing the implementations through test functions written according to the
conventions in the nose testing framework. This is continued throughout
the book and especially incorporated in the reformulated exercises. Test-
ing is challenging in programs containing unknown approximation errors,
so strategies for ﬁnding appropriate test problems have also become an
integral part of the fourth edition.
Many chapters now refer to the Online Python Tutor for visualizing
the program ﬂow. This is a splendid tool for learning what happens
with the variables and execution of statements in small programs. The
programming and introduced already in Chapter 1. The sections in
Chapter 4 have been reorganized, and the basic information on ﬁle
reading and writing was moved from Chapter 6 to Chapter 4. The fourth
edition clearly features three distinct parts: basic programming concepts
in Chapters 1-5, more advanced programming concepts in Chapters 6-9,
and programming for solving science problems in Appendix A-E.
Sections 4.9 and 4.10.2 have been rewritten to emphasize the impor-
tance of test functions. The information on how to make animations and