Robert Johansson
Numerical Python Scientific Computing and Data Science Applications with Numpy, SciPy and Matplotlib 2nd ed.
Robert Johansson
Urayasu-shi, Chiba, Japan
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484242452 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-4245-2 e-ISBN 978-1-4842-4246-9
https://doi.org/10.1007/978-1-4842-4246-9
Library of Congress Control Number: 2018966798
Robert Johansson 2019
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
To Mika and Erika.
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 ongoing, 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 focuses 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, the excellent Jupyter Notebook application, and the Spyder IDE.
In Chapter 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 cover core computational techniques that are pervasive in all types of computational work. Most of the methods from these chapters are found in the SciPy library.
In Chapter .
Starting with Chapter provide an introduction to the broad field of statistics and data analytics: a field that has been developing rapidly within and outside of the scientific Python community in recent years.
In Chapter , the final regular chapter in this book, two methods for speeding up Python code are introduced, using the Numba and Cython libraries.
The Appendix covers the installation of the software used in this book. To install the required software (mostly Python libraries), we use the conda package manager. Conda can also be used to create virtual and isolated Python environments, which is an important topic for creating stable and reproducible computational environments. The Appendix also discusses how to work with such environments using the conda package manager.
Source Code Listings
Each chapter in this book has an accompanying Jupyter Notebook that contains the chapters source code listings. These notebooks, and the data files required to run them, can be downloaded by clicking the Download Source Code button located at www.apress.com/9781484242452 .
Table of Contents
About the Author and About the Technical Reviewers
About the Author
Robert Johansson
is an experienced Python programmer and computational scientist, with a Ph.D. in Theoretical Physics from Chalmers University of Technology, Sweden. He has worked with scientific computing in academia and industry for over 10 years, and he has participated in both open source development and proprietary research projects. His open source contributions include work on QuTiP, a popular Python framework for simulating the dynamics of quantum systems; and he has also contributed to several other popular Python libraries in the scientific computing landscape. Robert is passionate about scientific computing and software development and about teaching and communicating best practices for bringing these fields together with optimal outcome: novel, reproducible, and extensible computational results. Roberts background includes 5 years of postdoctoral research in theoretical and computational physics, and he is now working as a data scientist in the IT industry.