Topics /

Math & Algorithms

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

2016
98

Prime After Prime

Are the prime numbers sprinkled randomly along the number line, like windblown seeds? Of course not: Primality is not a matter of chance but a product of simple arithmetic. A number is prime if and only if no smaller positive integer other than 1 divides it evenly.

99

Understanding gradient descent

Gradient descent is a standard tool for optimizing complex functions iteratively within a computer program. Its goal is: given some arbitrary function, find a minumum. For some small subset of functions - those that are convex - there's just a single minumum which also happens to be global. For most realistic…

104

What is the roundest country?

We can define roundness in many ways. For example, as you may know, the circle is the shape that given a fixed perimeter maximizes the area. This definition has many problems. One of the problems is that countries generally have chaotic perimeters (also known as borders), so they tend to be much longer than they seem…

106

Inspecting C's qsort Through Animation

The C standard library includes a qsort() function for sorting arbitrary buffers given a comparator function. The name comes from its original Unix implementation, “quicker sort,” a variation of the well-known quicksort algorithm. The C standard doesn’t specify an algorithm, except to say that it may be unstable (C99…

107

Dijkstra's Algorithm

I was at SCNA the other day, and someone approached me about TDD and Dijkstra’s algorithm. He wondered if you could find a sequence of tests that would lead you to the algorithm. This sounded like a fun little exercise, so I decided to give it a try here.

111

Spikey Spheres

A word of warning ... I'm presenting here something called an analogy. It's not perfect, it has problems, it's not exact, but there are ways in which it can aid your thinking. I'm giving a way of visualising high-dimensional spheres, a way that has its limitations, but which can help avoid making mistakes based on…

112

What is Symbolic Computation?

I've been reading a lot of Lisp books lately, some more advanced than others. All of the introductory books I've seen cover the idea of symbolic computation, but most of them breeze past it with just a few pages about "symbols" and "quoting". For many programmers coming from non-Lisp languages these are new, foreign…

113

Perlin noise

I used Perlin noise for the fog effect and title screen in Under Construction. I tweeted about my efforts to speed it up, and several people replied either confused about how Perlin noise works or not clear on what it actually is. I admit I only (somewhat) understand Perlin noise in the first place because I’ve…

114

The Busy Beaver Game

This month, a bunch of ‘logic hackers’ have been seeking to determine the precise boundary between the knowable and the unknowable. The challenge has been around for a long time. But on…

115

Zero-allocation Trie Traversal

As part of a demonstration in an upcoming article , I wrote a simple trie implementation. A trie is a search tree where the keys are a sequence of symbols (i.e. strings). Strings with a common prefix share an initial path down the trie, and the keys themselves are stored implicitly by the structure of the trie. It’s…

118

Toward an exploratory medium for mathematics

The world's oldest complete piece of surviving music is the 3,400-year-old Hurrian cult hymn . The hymn was found inscribed on clay tablets excavated from the ancient city of Ugarit, in modern-day Syria. Sometime after the hymn was composed, the idea of using notation to record music was lost. Writing two millennia…