Jupyter and CUDA on NSF Jetstream

NSF ACCESS is a fantastic high-performance computing program. If you’re affiliated with a university or other institution, you can upload a CV, write a paragraph describing your project, and get approved for several thousand CPU-hours within just a few days. If you don’t have existing grants it’s totally free. It even works if you’re a grad student, although then you’ll need your advisor to provide a form letter saying that you’re legit. But they even have suggested language for that.

Read More

Introducing ConGrad: Backend-Agnostic Conjugate Gradients in Python

When working at scale, it is often slow or impossible to form full-sized matrices. Instead, we make use of black-box functions to calculate matrix-vector products \(Ab\). There is thus a need for solvers which accept these functions instead of requiring matrix representations of our linear maps – and, in particular, for conjugate gradient solvers for the symmetric positive definite case.

Read More

In Which the Riesz Representation Theorem is Very Mysterious

Define \[\langle p, q \rangle = \int_{-1}^1 p(x)q(x)\,dx\] to be an inner product on \( \mathscr{P}_n(\mathbb{R}) \), the space of polynomials of degree at most \(n\) with real coefficients. Note that \(\varphi(p)=p(0)\) is a linear functional on \( \mathscr{P}_n(\mathbb{R}) \). Therefore, by the Riesz representation theorem, there must exist a unique polynomial \(q_n(x)\) such that \[\int_{-1}^1 p(x)q(x)\,dx = p(0)\] for all \(p\) with degree at most \(n\).

Read More

Generating Permutation-Respecting Partitions

One of the fun things about being specifically an applied mathematician is knowing when my colleagues are dealing with a combinatorial explosion. Recently, a friend of mine asked me if there were an easy way to determine how many of the partitions of a set of sixteen fixed elements obeyed a certain set of conditions. Doing this with brute force was a non-starter: there were over \(10^{10}\) of them, and if we were able to check sixteen thousand partitions per second the calculation would still have taken more than a week.

Read More

Sales Tax and Geometric Series

It is known that, for \(\vert r \vert<1\), \(\sum_{n=0}^\infty ar^n=\frac{a}{1-r}\). The usual proof goes something as follows: let \(S=\sum_{n=0}^\infty ar^n\). Then \(rS=\sum_{n=0}^\infty ar^{n+1}=\sum_{n=1}^\infty ar^n\). Subtracting, \(S-rS=\sum_{n=0}^\infty ar^n-\sum_{n=1}^\infty ar^n=a\), so \(S=\frac{a}{1-r}\) as required. It’s very elegant, but it seems a little bit magical.

Read More

A Linear Independence Problem from Mrs. Perrett

Back in high school, I had a math teacher called Shirley J. Perrett. (She would introduce herself as “Mrs. \(Pe^2r^2t^2\), but not in that order.”) She had a textbook called A2 Core Maths for Edexcel, by Emanuel, Wood, and Crawshaw. And that textbook had a problem in chapter 15 that none of the students Mrs. Perrett had ever taught had solved without hints.

Read More

Fourier Interpolation and Zero-Padding in the Middle

Let \(f\) be a function that you want to interpolate on the interval \([0, 1]\). Let \(k\) be some number of points. Say you know the values of \(f_i=f(i/k)\) for \(i=0, \dots, k-1\). If you knew that \(f\) were periodic with period \(1\), or in general if you knew that \(f\) decomposed into a sum of sinusoids with low frequencies, how might you leverage that knowledge to estimate \(f_{i+1/2}=f((i+1/2)/k)\)? (I’m assuming that the interpolation you have in mind exactly doubles the density of the grid. If you want to interpolate even more points, just repeat your procedure.)

Read More