Evan Curtin

Evan's Blog

About Me Blog Recipes CV

github linkedin

Math

png

Abstract linear algebra in Python

Lately I’ve been playing around with the anasazi library. It’s basically a library that implements algorithms to solve eigenvalue problems that are all completely unaware of the underling data structures. The way this is done is by implementing the algorithms in terms of an interface. Basically, this interface is a contract between whoever wrote the library, and whoever is using it. It’s a formal way for the library writer to say “If you give me an object that implements x, and y, this library will do Z with that object.

Use Numba for fast integrals

Here’s a quick tip to make your integrals super fast in python. Suppose you wanted to integrate a function in 3D. We can start by import nquad from scipy and defining our function. from scipy.integrate import nquad from math import sqrt, exp, sin, cos def f(x, y, z): return sin(cos(sqrt(exp(x)**2 + exp(y)**2 + exp(z)**2))) nquad makes it super easy to integrate a function in any number of dimensions, lets see: