Some numbers are easier to work with than others, especially for computer arithmetic—and even more so with weak processors. So let’s have a look at *easy numbers* that we can sometimes exploit to get faster code.

## Easy numbers

June 5, 2018## Yes? No? Maybe? (Part I)

March 20, 2018Initializing arrays, or any variable for that matter, is always kind of a problem. Most of the times, you can get away with a default value, typically zero in C#C++, but not always. For floats, for example, NaN makes much more sense. Indeed, it’s initialized to *not a number*: it clearly states that it is initialized, consciously, to not a value. That’s neat. What about integers? Clearly, there’s no way to encode a NaI (*not an integer*), maybe `std::numeric_limits::min()`, which is still better than zero. What about `bool`s?

Bool is trickier. In C++, bool is either false or true, and weak typing makes everything not zero true. However, if you assign 3 to a bool, it will be “normalized” to true, that is, exactly 1. Therefore, and not that surprisingly, you can’t have true, false, and *maybe*. Well, let’s fix that.

## Paeth’s Method (Square Roots, Part VII)

March 13, 2018In *Graphics Gems* [1], Paeth proposes a fast (but quite approximate) method for the rapid computation of hypotenuse,

.

The goal here is to get rid of the big bad because it is deemed “too expensive”—I wonder if that’s still actually true. First, he transforms the above equation:

## Square roots (Part VI)

February 20, 2018I’ve discussed algorithms for computing square roots a couple of times already, and then some. While sorting notes, I’ve came across something interesting: Archytas’ method for computing square roots.

Archytas’ method is basically the old Babylonian method, where you first set

,

,

and iterate

,

,

until desired precision is achieved (or the scribe is exhausted).

## Taylor Series

December 19, 2017A Taylor series for a function around that is times differentiable is given by

or

,

where is the th derivative of at .

Have you ever wondered where the coefficients in a Taylor series come from? Well, let’s see!

## Building a large text corpus (Part I)

December 12, 2017Getting good text data for language-model training isn’t as easy as it sounds. First, you have to find a large corpus. Second, you must clean it up!