Topics /

Math & Algorithms

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

2024
154

Regular expression matching can be simple and fast (2007)

This is a tale of two approaches to regular expression matching. One of them is in widespread use in the standard interpreters for many languages, including Perl. The other is used only in a few places, notably most implementations of awk and grep. The two approaches have wildly different performance characteristics:

159

The power of two random choices

In many large-scale web services, multiple layers of stateless and stateful services are seperated by load balancers. Load balancing can be done with dedicated hardware, with dedicated software load balancers, using DNS trickery or through a load-balancing mechanism in the client. In large systems, the resources and…

163

Solving Probabilistic Tic-Tac-Toe

This morning, I came accross Cameron Sun’s Probabilistic Tic-Tac-Toe on HN . However, the comments were disappointing, with people proposing probabilistic models, linear programming, minimax algorithms, and heuristic evaluations to develop AI approaches for the game, none of which quite correct. In this post, I’ll…

164

Industrious Dice

I’m a professional mathematician. That means somebody pays me to do math. I’m also a recreational mathematician. That means you might have to pay me to get me to stop. Wearing my recreational mathe…

177

Compiling with Constraints

There are lots of interesting little subproblems in compilation like instruction selection, register allocation and instruction scheduling. These can be expressed in declarative interlinked way to constraint solvers.

178

Legendre transform, better explained (2017)

The way that most physicists teach and talk about partial differential equations is horrible, and has surprisingly big costs for the typical understanding of the foundations of the field even among professionals. The chief victims are students of thermodynamics and analytical mechanics, and I've me

180

An alternative construction of Shannon entropy

The underpinning of information theory is Shannon’s formula for the entropy H of a discrete probability distribution P. Derived in 1948 in the paper “A mathematical theory of communication”, this is given by \[ H[P] = -\sum_{i=1}^N p_i \log p_i \] where \( p_i = p(x_i) \) is the probability of sampling \( x_i \) from…