Introduction
Scientific and numerical computing is a booming field in research, engineering, and analytics. The
revolution in the computer industry over the last several decades has provided new and powerful tools for
computational practitioners. This has enabled computational undertakings of previously unprecedented
scale and complexity. Entire fields and industries have sprung up as a result. This development is still on
going, and it is creating new opportunities as hardware, software, and algorithms keep improving. Ultimately
the enabling technology for this movement is the powerful computing hardware that has been developed in
recent decades. However, for a computational practitioner, the software environment used for computational
work is as important as, if not more important than, the hardware on which the computations are carried
out. This book is about one popular and fast growing environment for numerical computing: the Python
programming language and its vibrant ecosystem of libraries and extensions for computational work.
Computing is an interdisciplinary activity that requires experience and expertise in both theoretical
and practical subjects: a firm understanding of mathematics and scientific thinking is a fundamental
requirement for effective computational work. Equally important is solid training in computer programming
and computer science. The role of this book is to bridge these two subjects by introducing how scientific
computing can be done using the Python programming language and the computing environment that
has appeared around this language. In this book the reader is assumed to have some previous training in
mathematics and numerical methods, and basic knowledge about Python programming. The focus of the
book is to give a practical introduction to computational problem solving with Python. Brief introductions to
the theory of the covered topics are given in each chapter, to introduce notation and remind readers of the
basic methods and algorithms. However, this book is not a self-consistent treatment of numerical methods.
To assist readers that are not previously familiar with some of the topics of this book, references for further
reading are given at the end of each chapter. Likewise, readers without experience in Python programming
will probably find it useful to read this book together with a book that focus on the Python programming
language itself.
How This Book is Organized
The first chapter in this book introduces general principles for scientific computing, and the main
development environments that are available for work with computing in Python: The focus is on IPython
and its interactive Python prompt and its excellent notebook application, and the Spyder IDE.
In Chapter 2, an introduction to the NumPy library is given, and here we also discuss more generally
array-based computing and its virtues. In Chapter 3 we turn our attention to symbolic computing –
which in many respects complements array-based computing – using the SymPy library. In Chapter 4
we cover plotting and visualization using the Matplotlib library. Together, Chapters 2 to 4 provide the
basic computational tools that will be used for domain specific problems throughout the rest of the book:
numerics, symbolics, and visualization.
In Chapter 5, the topic of study is equation solving, which we explore with both numerical and
symbolic methods, using the SciPy and SymPy libraries. In Chapter 6, we explore optimization, which is
a natural extension of equation solving. Here we mainly work with the SciPy library, and briefly with the
cvxopt library. Chapter 7 deals with interpolation, which is another basic mathematical method with many
xxi