## Preface

While maintaining the main structure of the first edition, this revised edition of *Learning SciPy for Numerical and Scientific Computing* includes a set of companion IPython Notebooks. This will help students, researchers, and practitioners modify and incorporate in their own work, the set of tested code snippets that are presented in the book, as the pedagogical strategy. This will also show and illustrate the computing power that SciPy brings to the fingertips of anyone interested in performing numerical computation via the unique flexibility offered by the Python computer language.

We should mention, however, that the IPython Notebooks will make sense to anyone starting in the field only if they are read alongside the corresponding section in the book, helping you to develop skills in the use of SciPy to solve large scale numerical problems while gaining understanding of the conditions and limitations associated with the modules contained in SciPy. Certainly, the already knowledgeable reader will find pleasure as they encounter material they already know, but will be challenged to devise better ways to accomplish with the same level of clarity presented in the book with the many computational tasks used to illustrate the functionality of SciPy.

SciPy has been an integral part of the computational environment of choice for many scientists for years. One of our challenges today is to bring together professionals with different backgrounds, technologies, and expertise in software (from the pure mathematician, to the hardcore engineer) to contribute independent of their working environments.

SciPy in Python is a perfect platform to coordinate projects in a smooth, reliable, and coherent environment. It allows performing most tasks with ease; reason being that many dedicated software tools easily integrate with the core features of SciPy, therefore, interfacing with non-Python-based software packages and tools is becoming increasingly simple.

In summary, this book presents the most robust programming environment to date. We will show you how to use this system from basic manipulation of data, to a very detailed exposition through examples in different branches of science and engineering.

## What this book covers

Chapter 1, *Introduction to SciPy*, shows the benefits of using the combination of Python, NumPy, SciPy, and matplotlib as a programming environment for scientific purposes. You will learn how to install, test, and explore the environments, use them for quick computations, and figure out a few good ways to search for help. A brief introduction on how to open the companion IPython Notebooks that comes with this book is also presented.

Chapter 2, *Working with the NumPy Array As a First Step to SciPy*, explores in depth the creation and basic manipulation of the object array used by SciPy, as an overview of the NumPy libraries.

Chapter 3, *SciPy for Linear Algebra*, covers applications of SciPy to applications with large matrices, including solving systems or computation of eigenvalues and eigenvectors.

Chapter 4, *SciPy for Numerical Analysis*, is without a doubt one of the most interesting chapters in this book. It covers with great detail the definition and manipulation of functions (one or several variables), the extraction of their roots, extreme values (optimization), computation of derivatives, integration, interpolation, regression, and applications to the solution of ordinary differential equations.

Chapter 5, *SciPy for Signal Processing*, explores construction, acquisition, quality improvement, compression, and feature extraction of signals (in any dimension). It is covered with beautiful and interesting examples from the field of image processing.

Chapter 6, *SciPy for Data Mining*, covers applications of SciPy for collection, organization, analysis, and interpretation of data, with examples taken from statistics and clustering.

Chapter 7, *SciPy for Computational Geometry*, explores the construction of triangulation of points, convex hulls, Voronoi diagrams, and applications, including the solving of the two dimensional Laplace Equation via the Finite Element Method in a rectangular grid. At this point in the book, it will be possible to combine techniques from all the previous chapters to show state-of-the-art research performed with ease with SciPy, and we will explore a few good examples from Material Science and Experimental Physics.

Chapter 8, *Interaction with Other Languages*, introduces one of the main strengths of SciPy—the ability to interact with other languages such as C/C++, Fortran, R, and MATLAB/Octave.

## What you need for this book

To work with the examples and try out the code in this book, all you need is a recent build of Python (2.7 or higher) with the libraries NumPy, SciPy, and matplotlib. Recipes to install all these are provided throughout the book.

## Who this book is for

This book is for scientists, engineers, programmers, or analysts with knowledge of Python. For some of the sections, a decent command over linear algebra, calculus, and some statistics is needed to understand some of the concepts, but otherwise this book is mostly self-contained.

## Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the `include`

directive."

A block of code is set as follows:

solve(A, b, sym_pos=False, lower=False, overwrite_a=False, overwrite_b=False, debug=False) spsolve(A, b[, permc_spec, use_umfpack])

The reader with the required background should recognize the Python prompt `>>>`

followed by a space and then the code field. Any command-line input or output is written as follows:

>>> from scipy import stats>>> result=scipy.stats.bayes_mvs(scores)

**New terms** and **important words** are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the **Next** button moves you to the next screen".

### Note

Warnings or important notes appear in a box like this.

### Tip

Tips and tricks appear like this.

## Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to `<[email protected]>`

, and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

## Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

### Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

### Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/7702OS_ColoredImages.pdf.

### Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the **errata** **submission** **form** link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

### Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at `<[email protected]>`

with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

### Questions

You can contact us at `<[email protected]>`

if you are having a problem with any aspect of the book, and we will do our best to address it.