This is one of the 100 recipes of the IPython Cookbook, the definitive guide to high-performance scientific computing and data science in Python.

In [ ]:

```
n = 100000
```

In [ ]:

```
%timeit sum([1. / i**2 for i in range(1, n)])
```

In [ ]:

```
%%timeit s = 0.
for i in range(1, n):
s += 1. / i**2
```

In [ ]:

```
import numpy as np
```

In [ ]:

```
%timeit np.sum(1. / np.arange(1., n) ** 2)
```

You'll find all the explanations, figures, references, and much more in the book (to be released later this summer).

IPython Cookbook, by Cyrille Rossant, Packt Publishing, 2014 (500 pages).