Topics /

Math & Algorithms

The most popular blog posts about math & algorithms on Hacker News. 2,851 posts.

Any year
1921

Ramanujan Factorial Approximation (2012)

Ramanujan came up with an approximation for factorial that resembles Stirling's famous approximation but is much more accurate. As with Stirling's approximation, the relative error in Ramanujan's approximation decreases as n gets larger. Typically these approximations are not useful for small values of n. For n = 5…

1924

Categories from scratch

Note The latest version of this document can be found online at https://dr-knz.net/categories-from-scratch.html. Alternate formats: Source, PDF. Prologue The concept of category from mathematics happens to be useful to computer programmers in many ways. Unfortunately, all “good” explanations of categories so far have…

1935

Beyond Bézier Curves (2013)

There is a new feature of Pages and Keynote, not mentioned in any of Apple’s publicity nor in any press coverage I’ve seen, that is really very interesting. Perhaps it will even one day prove to ha…

1936

Step-by-Step Math

Have you ever given up working on a math problem because you couldn’t figure out the next step? Wolfram|Alpha can guide you step by step through the process of solving many mathematical problems, from solving a simple quadratic equation to taking the integral of a complex function.

1948

Anatomy of a Lean proof for software engineers

Intro I recently worked through a problem from a theory of computation textbook that asked me to prove a property of a language using finite automata. The informal proof is a simple constructive proof where you build an automaton and show that it recognizes the language. This is kind of similar to program…

1950

A Fairly Fast Fibonacci Function

A common example of recursion is the function to calculate the $n$-th Fibonacci number: def naive_fib(n): if n < 2: return n else: return naive_fib(n-1) + naive_fib(n-2) This follows the mathematical definition very closely but it’s performance is terrible: roughly $\mathcal{O}(2^n)$. This is commonly patched up with…