Topics /

Math & Algorithms

The most popular blog posts about math & algorithms on Hacker News. 221 posts.

2023
97

A trick to eliminate 2π (sometimes)

As a physicist, I’ve learned that the presence of 2 π 2\pi 2 π [▼] [ Or rather τ \tau τ , as it should actually be called . ] in a formula usually spells trouble. It’s kind of annoying to write by hand, easy to forget, and it’s dimensionless, so you can’t easily check if you forgot to divide or multiply by it…

99

My favorite prime number generator

Many years ago I've re-posted a Stack Overflow answer with Python code for a terse prime sieve function that generates a potentially infinite sequence of prime numbers ("potentially" because it will run out of memory eventually). Since then, I've used this code many times - mostly because it's short and clear. In this…

102

The Smallest Hash Table

This December I once again did the Advent of Code , in Rust. If you are interested, my solutions are on Github. I wanted to highlight one particular solution to the day 2 problem as it is both optimized completely beyond the point of reason yet contains a useful technique. For simplicity we’re only going to do part 1…

106

Reflected Diffusion Models

Diffusion models are trained to reverse a stochastic process through score matching. However, a lot of diffusion models rely on a small but critical implementation detail called thresholding. Thresholding projects the sampling process to the data support after each discretized diffusion step, stabilizing generation at…

107

We're Knot Friends

It’s April Cools again. For a few summers in high school and undergrad, I was a day camp counselor. I’ve written before about how it helped me develop storytelling skills, but recently I thought of it again because, while I was cleaning out a closet full of old junk, I happened upon a bag of embroidery thread. While…

111

Bitwise Division

Integer division is expensive. Much more expensive than multiplication. Much, much more expensive than addition. If you’re trying to make some integer operations really fast it’s bad news if you need to do division.

115

Lindenmayer systems

A Lindemayer system or LSystem for short consists of an alphabet of symbols that can be used to make strings, a collection of production that expand each symbol into some larger string of symbols, an initial “axiom” string from which to begin construction, and a mechanism for translating the generated strings into…

116

The Fibonacci Matrix

When you think about the Fibonacci sequence, you probably imagine a swirling vortex of oscillating points stretching outwards to infinity: Okay, no, obviously you don’t. Yet.

120

C.R. Rao: A Life in Statistics (2020)

Presently into the 100th year of his life of vast experience, living in his Buffalo residence, here is a video message communicated by his daughter when he turned 99, at the beginning of a year-long celebration, with conferences in his honour at various places.