A Special Case…

March 26, 2013

Expressions with floors and ceilings (\lfloor x \rfloor and \lceil y \rceil) are usually troublesome to work with. There are cases where you can essentially remove them by a change of variables.


Turns out, one form that regularly comes up in my calculations is \lfloor \lg x \rfloor, and it bugged me a while before I figured out the right way of getting rid of them (sometimes).

Read the rest of this entry »

Shallow Constitude

March 19, 2013

In programming languages, there are constructs that are of little pragmatic importance (that is, they do not really affect how code behaves or what code is generated by the compiler) but are of great “social” importance as they instruct the programmer as to what contract the code complies to.


One of those constructs in C++ is the const (and other access modifiers) that explicitly states to the programmer that this function argument will be treated as read-only, and that it’s safe to pass your data to it, it won’t be modified. But is it all but security theater?

Read the rest of this entry »

Compressed Series (Part II)

March 12, 2013

Last week we looked at an alternative series to compute e, and this week we will have a look at the computation of e^x. The usual series we learn in calculus textbook is given by

\displaystyle e^x=\sum_{n=0}^\infty \frac{x^n}{n!}

We can factorize the expression as

Read the rest of this entry »

Compressed Series (Part I)

March 5, 2013

Numerical methods are generally rather hard to get right because of error propagation due to the limited precision of floats (or even doubles). This seems to be especially true with methods involving series, where a usually large number of ever diminishing terms must added to attain something that looks like convergence. Even fairly simple sequences such as

\displaystyle e=\sum_{n=0}^\infty \frac{1}{n!}

may be complex to evaluate. First, n! is cumbersome, and \displaystyle \frac{1}{n!} becomes small exceedingly rapidly.

Read the rest of this entry »