What’s so natural about ‘e’?

In this post I’m going to talk about the natural logarithm, continuous growth and their relationship. In the process, I’m also going to derive e.

The story begins with the exponential function: y = a ^ x . We want to know its derivative.

\dfrac{dy}{dx} = \dfrac {{a ^ {x+\Delta x}} - {a ^ x}}{\Delta x}  = {a ^ x} \times \dfrac {{a ^ \Delta x} - 1}{\Delta x}

To be continued…

Euler’s number

Euler’s number (e) and an understanding of its not-so-obvious relationship with continuous growth has eluded so many of us, it’s only apt that we take some time out of our daily lives to sit down and have a little chat.

An Example
Interest earned on an investment of $100 @ 10% annual interest-rate is $100 a year. Usually, this $10 will be paid out at the end of the year. This can be modeled as:

\boxed{ \begin{aligned} \hspace*{5pt} Interest &= Principal \times Rate \times Time \\ i &= p \times r \times t \\ \$10 &= \$100 \times 0.1 \times 1 \hspace*{5pt} \end{aligned}}.

If you don’t want to wait for one whole year to earn interest, you may ask for the accrued interest to be paid every six months. In that case, you earn $5 twice a year.

\boxed{ \begin{aligned} \hspace*{5pt} i &= p \times r \times t \\ \$10 &= \$100 \times \dfrac{0.1}{2} \times 2 \hspace*{5pt} \end{aligned}}.

Following this logic, interest could be earned as frequently as desired while the total interest earned in a year remains the same. For example, you could demand 100 interest payments to be made at equal intervals of time within a year, net interest earned still being $10 per annum.

\boxed{ \begin{aligned} \hspace*{5pt} i &= p \times r \times t \\ \$10 &= \$100 \times \dfrac{0.1}{100} \times 100 \hspace*{5pt} \end{aligned}}.

Okay, so now you’re getting 100 interest payments a year. By the end of the year, you’re able to add 10% to your investment.

\boxed{ \begin{aligned} \hspace*{5pt} Amount_{simple} &= Principal \times \left( 1 + Rate \times Time \right) \\  &= p \times \left( 1 + rt \right) \\  &= \$100 \times \left( 1 + \dfrac{0.1}{100} \times 100 \right) \hspace*{5pt} \\ &= \$110 \end{aligned}}.

You’re happy with the way things are until a friend shows up who tells you there’s a way to make more money, and it’s by re-investing the interest earned! Between each interest payment, you add the previously earned interest to the principal amount, thus changing the interest that will be earned next. Unlike previous scheme, the amount of interest paid keeps increasing. As the number of payments (n) approach infinity, then:

\boxed{ \begin{aligned} \hspace*{5pt} Amount_{continuous} &= Principal \times \left( 1 + Rate \right)^{Time} \\  &= p \times \left( 1 + r \right)^t \\  &= \$100 \times \left( 1 + \dfrac{0.1}{n} \right)^{nt} \hspace*{5pt} \\ &\approx \$110.51 \end{aligned}}. 

To generalize, let’s say x = 0.1. Then:


And so, Amount_{continuous} can be rewritten as:

\boxed{ \begin{aligned} \hspace*{5pt} Amount_{continuous} &= \$100 \times \left( 1 + \dfrac{0.1}{100} \right)^{100} \hspace*{5pt} \\ &= p \times \left(e ^ {xt} \right) \\  &\approx \$110.51 \end{aligned}}.

Bayes’ Rule Explained

You wake up one morning and feel something isn’t right. Your head hurts. You’re aware that recently there’s this virus on the loose that’s causing people to lose their minds and you worry that you might be infected. This disease is aptly named Mindlostisis and no cure exists. So you rush to the nearest hospital and get yourself tested. Test comes positive. Doctor tells you 90% of people who have Mindlostisis test positive. Should you be worried?

No, not yet. Because what if 90% of people who don’t have Mindlostisis also test positive? The doctor has given you a number that you don’t care about, namely the probability of testing positive if you have the disease. Instead, what you really want to know is the probability of having the disease if you test positive. I’ll now introduce some notation that will make talking about probabilities easier.

P(T) = Probability of the test coming positive.
P(M) = Probability of having Mindlostisis.
P(T|M) = Probability of a positive test given that you have Mindlostisis.
P(M|T) = Probability of having Mindlostisis given that the test comes positive.

Rephrasing what’s been said earlier, the doctor gave you P(T|M) when it’s P(M|T) that you’re really interested in. And this is where Bayes’ Rule comes in:

\boxed{ \hspace*{5pt} P(M|T)={\dfrac{{P(T|M) \times P(M)}} {P(T)}} \hspace*{5pt}}.

This equation is far from obvious so let’s try and understand it using a Venn diagram.
Bayes' Rule Explained

U = Set of all people in the city.
X = Set of all people that test positive.
Y = Set of all people that have Mindlostisis.
A = Set of all people that have Mindlostisis and test positive.
Y-A = Set of all people that have Mindlostisis but do not test positive.

Additionally, total number of people in any set is denoted in lowercase. For example, total number of people in X is x. Using above-established notation and Venn diagram, it’s evident that P(T|M), which is 90% as the doctor said, equals:

\boxed{ \hspace*{5pt} {P(T|M) = \dfrac{a}{y}} = 0.9\hspace*{5pt}}.

What you want to know is P(M|T), which is the ratio of number of people in A and number of people in X:

\boxed{ \hspace*{5pt} {P(M|T) = \dfrac{a}{x}}\hspace*{5pt}}.

In order to calculate P(M|T), we do need P(T|M) but that’s not enough. Something more is required, and let that something be s.

P(M|T) = P(T|M) \times s \\  \\ \Rightarrow s = \dfrac{P(M|T)}{P(T|M)} = \dfrac{a}{x} \times \dfrac{y}{a} = \dfrac {y}{x} = \dfrac {y}{u} \times \dfrac {u}{x} = \dfrac{P(M)}{P(T)}.

Putting it all together we get:

\boxed{ \hspace*{5pt} P(M|T)={\dfrac{{P(T|M) \times P(M)}} {P(T)}} \hspace*{5pt}}.

Clearly, to be able to tell your chances of having the disease given a positive test, you not only need to know what the doctor said, but also: (P(M) / P(T)).

Mandelbrot Set

For my viewing pleasure.

Mandelbrot Set

R code:


mandelbrot_set <- function(precision) {
  is_mandelbrot_point <- function(a, b) {
    orig_a <- a
    orig_b <- b
    n_iters <- 30 # defines escape propensity
    for (i in seq(n_iters)) {
      x <- a
      y <- b
      a <- (x^2 - y^2) + orig_a
      b <- (2*x*y) + orig_b
    # If the number escapes to infinity, it's not a mandelbrot point.
    if (is.nan(a) || is.nan(b))

  n <- 3 # axes restricted to -3 to +3
  x <- NULL
  y <- NULL
  for (i in seq(-n, n, precision))
    for (j in seq(-n, n, precision)) {
      flag <- is_mandelbrot_point(i, j)
      if (flag) {
        x <- c(x, i)
        y <- c(y, j)
  data.frame(x, y)

mdat <- mandelbrot_set(.01)
ggplot(mdat, aes(x, y)) + geom_point(color="brown", size=.1) +
  theme(axis.title=element_blank(), axis.text=element_blank(),

Linux – A Brief History

The other day I was wondering what is it that makes Linux popular. Although I’ve been using Linux for over a decade, only now I decided to look back and see how Linux got into being. What follows is my understanding of Linux’s history.

Sometime in the 1960s, Bell Labs and MIT were working on a timesharing OS they called Multics. Soon Bell Labs pulled out of it thinking it wasn’t going anywhere. Ken Thompson – a programmer at Bell Labs at the time – decided to create his own OS based on Multics. By 1969, a team led by Ken Thompson had a decent OS running on a PDP-7 machine. They called it Unix.

Around 1972, Dennis Ritchie invented C, and soon made it possible to write Unix in C! This was unprecedented. Until then, all OSs were written in assembly and custom-made for the hardware it came with. To make it possible to write an OS in C meant being able to write an OS for any hardware that had a C compiler available. Unix was successfully ported on different kinds of hardware and that made it highly popular.

Ken Thompson spent a couple years at University of California at Berkeley, and out of there came another flavor of Unix called BSD. AT&T had its own they called System V. There were many other implementations of ‘Unix’ with extensions and that necessitated a need for standardization (one such standard is IEEE’s POSIX specification).

While all this was happening in Universe A, Universe B had a different stew brewing. Richard Stallman – a programmer at MIT – wasn’t happy with the state-of-affairs with the Unix business. Long story short, he wanted it free. Free as in being able to modify software. Stallman was a hacker, and what’s a hacker without the source code. He set out to launch his GNU project that aimed at creating a free Unix-like OS, because Unix wasn’t free. This project resulted in a lot of open-source software, but lacked a kernel. Linus Torvalds – a university student from Helsinki – created a Unix-like kernel for free use, and invited others to contribute. Soon the project gained momentum, and combined with the GNU project, a full-fledged Unix-like system was born, called Linux.