Wednesday, December 7, 2011

Let's find Euler's number - e

The Euler’s number is another mathematical constant which is an irrational number similar to $latex \pi$. In addition, this is the base of the natural logarithm. Few of the interesting things related to this number are as follows;
  • $latex \displaystyle e=\lim_{n\rightarrow\infty} \bigg(1+\frac{1}{n}\bigg)^n$.
  • $latex \displaystyle e = \sum_{n=0}^\infty {\frac{1}{n!}}$.
  • When $latex f(x)=e^x$, the first derivation of the function (gradient of $latex f$ at point $latex x$) is $latex f^1(x)=e^x$. Moreover, for any integer $latex n$ (positive for differentiation and negative for integration neglecting the arbitrary constant), the n-th derivation is $latex f^n(x)=e^x$.
  • As $latex x\rightarrow\infty$, $latex e^x\rightarrow\infty$ and as $latex x\rightarrow-\infty$, $latex e^x\rightarrow0$. And $latex e^0=1$ which is an obvious fact. The function $latex e^{-x}$ is the reflection of $latex e^x$ around the y-axis.

Today we are going to use a simple technique to estimate the value of ‘$latex e$’ (You probably can search the value from the internet easily). We are going to use the plots in the figure below.


We have $latex y=e^{-x}$ curve and it is bounded by two step functions. In the step functions, the width of each column (step size) is $latex \frac{1}{n}$, i.e. the unit length of x-axis is divided in to '$latex n$' segments. 

Let's look at the two overlapped columns starting from point '$latex x$'.
  • Height of the tall column is $latex e^{-x}$.
  • Height of the short column is $latex e^{-(x+\frac{1}{n})}$.
  • Width of both columns are $latex \frac{1}{n}$.

Therefore, the surface area of the tall column is $latex \frac{1}{n}\times{e^{-x}}$ and for the short column it is $latex \frac{1}{n}\times{e^{-(x+1/n)}}=\frac{e^{-1/n}}{n}\times{e^{-x}}$.

With the knowledge of calculus, we can say that the area under the curve '$latex y$' within the width of those columns is $latex \int_x^{(x+1/n)}e^{-x}dx$. 

We can observe that the area under the curve is larger than the area of short column, but smaller than the area of the tall column. Thus,
$latex \frac{e^{-1/n}}{n}{e^{-x}}<\int_x^{(x+1/n)}e^{-x}dx<\frac{1}{n}{e^{-x}}$

Now, let us add together all the areas starting from $latex x=1$ to the infinity by the step size of $latex \Delta{x}={1}/{n}$,

$latex \displaystyle \sum_{x=1,\Delta{x}=\frac{1}{n}}^{\infty}\frac{e^{-1/n}}{n}{e^{-x}}<\displaystyle\sum_{x=1,\Delta{x}=\frac{1}{n}}^{\infty}\int_x^{(x+1/n)}e^{-x}dx <\displaystyle\sum_{x=1,\Delta{x}=\frac{1}{n}}^{\infty}\frac{1}{n}{e^{-x}}$

$latex \frac{e^{-1/n}}{n}\displaystyle\sum_{x=1,\Delta{x}=\frac{1}{n}}^{\infty}{e^{-x}}<\int_1^{\infty}e^{-x}dx<\frac{1}{n}\displaystyle\sum_{x=1,\Delta{x}=\frac{1}{n}}^{\infty}{e^{-x}}$

If you look at the infinite summations, you may notice that both of them are geometric progressions. Right series has $latex \frac{e^{-1}}{n}$ as the first term and for the left series it is $latex \frac{e^{-1}e^{-1/n}}{n}$ and, both of them have $latex e^{-1/n}$ as the common ratio (it is less than 1 which we take by the fact of that '$latex e$' is larger than 1).

Thus, by the knowledge of infinite sum of geometric series and integration, we can re-write above inequalities as below.
$latex \frac{(e^{-1}e^{-1/n})/n}{1-e^{-1/n}}<e^{-1}<\frac{(e^{-1})/n}{1-e^{-1/n}}$
$latex \frac{e^{-1/n}}{n}<1-e^{-1/n}<\frac{1}{n}$
$latex \frac{1}{n}<e^{1/n}-1<\frac{e^{1/n}}{n}$

By considering left-middle terms and middle-right terms as separate inequalities, we can simplify above furthermore and later combine it as follows;
$latex \frac{n+1}{n}<e^{1/n}<\frac{n}{n-1}$
$latex (\frac{n+1}{n})^n<e<(\frac{n}{n-1})^n$

There it is. By using any positive integer for '$latex n$', we can estimate the value of '$latex e$'.

Examples: 
  1. Let $latex n=8$. Then,

$latex (\frac{8+1}{8})^4<e<(\frac{8}{8-1})^8$
$latex 2.56578<e<2.91028$

However, this approach converges very slowly. Let's say that we need to find the exact answer for $latex k$ decimal points. That implies $latex (\frac{n}{n-1})^n-(\frac{n+1}{n})^n<10^{-k}$ need to be satisfied. Now we are going to simplify this.
$latex (\frac{n}{n-1})^n-(\frac{n+1}{n})^n<10^{-k}$
$latex (\frac{n^2}{n^2-1})^n-1<(\frac{n}{n+1})^n10^{-k}$

We know that as '$latex n$' increases the lower bound increases. Therefore, the reciprocal decreases. From above example we can guess that the lower bound never reaches to 3 which means the reciprocal never drops below 1/3. So above inequality is simplified with that assumption ( $latex \forall{n\in\mathbb{Z}^+},(\frac{n}{n+1})^n<\frac{1}{3}$ ).

Therefore if we can find an '$latex n$' which satisfy $latex (\frac{n^2}{n^2-1})^n-1<\frac{1}{3}10^{-k}$ for given '$latex k$', using that '$latex n$' we can estimate the value of '$latex e$' for '$latex k$' decimal points correctly.

Examples: 
  1. Let $latex n=100$. Then $latex 3[(\frac{n^2}{n^2-1})^n-1]=0.03015<10^{-1}$. Therefore, $latex (\frac{100+1}{100})^{100}=2.7048$ gives the estimation for one decimal point, which is $latex e\simeq2.7$.
  2. Let $latex n=1000$. Then $latex 3[(\frac{n^2}{n^2-1})^n-1]=0.0030015<10^{-2}$. Therefore, $latex (\frac{100+1}{100})^{100}=2.7169$ gives the estimation for two decimal point, which is $latex e\simeq2.71$.
  3. Let $latex n=10000$. Then $latex 3[(\frac{n^2}{n^2-1})^n-1]=0.000300015<10^{-3}$. Therefore, $latex (\frac{1000+1}{1000})^{1000}=2.71814$ gives the estimation for three decimal point, which is $latex e\simeq2.718$.
Hope you got the idea. And have fun with calculating to large number of decimal points.

From wikipedia I got it for 50 decimal points, which is
e = 2.71828182845904523536028747135266249775724709369995.


Monday, December 5, 2011

The infinite sum of 1/xⁿ


”Convergence of series” is a quite interesting topic during high school mathematics. A popular such series is $latex \sum_{x\in\mathbb{Z}^+}(\frac{1}{x^n})$ where $latex n$ is a positive integer. When $latex n>1$, there were lots of examples to determine the convergence and finding the sum up to general $latex N$ terms.


However, it is not true for $latex n=1$ and I always wondered how it happens. Therefore, I thought to share the proof with a simple graphical approach as follows.

Let’s look at the figure.

We have two curves: $latex y_1=\frac{1}{x^n}$ and $latex y_2=\frac{1}{(x+1)^n}$. In between them, I drew a bar-graph and you may notice that the height of each column is equivalent to $latex y=\frac{1}{{\lfloor x\rfloor}^n}$ where $latex \lfloor x\rfloor$ is the closest lower integer of $latex x$.
( Eg: $latex \lfloor 2.5 \rfloor = \lfloor 2 \rfloor = 2$ )
Now, if we try to calculate the area of $latex k$-th column, it will be $latex \frac{1}{k^n}\times 1=\frac{1}{k^n}\$. Therefore, what will be the sum of area of all columns? Yes, it is our nice buddy series, $latex \sum_{x=1}^{\infty}(\frac{1}{x^n})$. Pretty interesting, isn’t it?

Now look at the area under each curve for positive $latex x$ values.

We can see that each column is popping out a little bit from the curve $latex y_2$. Therefore, we can say that the area under curve $latex y_2$ is less than the sum area of columns.

And it is the opposite for curve $latex y_1$. Every column is underneath the curve and thus its area is larger than the sum area of columns. We know that $latex y_1$ tends to infinity when it is close to 0. Thus, we modify our argument like this. For $latex x>1$, we can say that the area under $latex y_1$ is larger than the sum area of columns excluding the first column. The area of the 1st column is 1. Then, we can say the sum area of columns is less than the area under the curve $latex y_1$ for $latex x>1$ plus 1.

(Area under $latex y_2$ for $latex x>0$ ) < $latex \sum_{x=1}^{\infty}(\frac{1}{x^n})$ < (1 + Area under $latex y_1$ for $latex x>1$ )


The guys who play with calculus know that the area under a given curve $latex f(x)$ between the interval $latex [a,b]$ is $latex \int_a^b|f(x)|dx$. Therefore, we can make above relation in a mathematical form as following; 
$latex \int_0^\infty\frac{1}{(x+1)^n}dx < \sum_{x>0}(\frac{1}{x^n}) <1 + \int_1^\infty\frac{1}{x^n}dx$,
where $latex x \in \mathbb{Z}^+$.

Let’s solve above relations.
  • For $latex n=1$,

$latex \int_0^\infty\frac{1}{(x+1)}dx < \sum_{x>0}(\frac{1}{x}) < 1 +\int_1^\infty\frac{1}{x}dx$
$latex \ln(x+1)|_0^\infty < \sum_{x>0}(\frac{1}{x}) <1 + \ln(x)|_1^\infty$
$latex \infty < \sum_{x>0}(\frac{1}{x}) < \infty$

Yeah, $latex \sum_{x>0}(\frac{1}{x})$ is not going to converge.

  • For $latex n > 1$,

$latex \int_0^\infty\frac{1}{(x+1)^n}dx < \sum_{x>0}(\frac{1}{x^n}) <1 + \int_1^\infty\frac{1}{x^n}dx$
$latex \frac{1}{(1-n)(x+1)^{n-1}}|_0^\infty < \sum_{x>0}(\frac{1}{x^n}) < 1 + \frac{1}{(1-n)x^{n-1}}|_1^\infty$
 $latex \frac{1}{(n-1)} < \sum_{x > 0}(\frac{1}{x^n}) < \frac{n}{(n-1)} $
As $latex n\rightarrow\infty$,
$latex 0 < \sum_{x > 0}(\frac{1}{x^n}) < 1 $
Series converges.

Furthermore, for $latex n < 1$ and $latex \forall x \in \mathbb{Z}^+$, 
$latex \frac{1}{x} <\frac{1}{x^n} $
$latex \sum_{x>0}(\frac{1}{x} )<\sum_{x>0}(\frac{1}{x^n})$
          $latex \infty < \sum_{x>0}(\frac{1}{x^n})$

Therefore, we can conclude that,
  • For $latex n > 1$ ; $latex \sum_{x=1}^{\infty}(\frac{1}{x^n})$ converges.
  • For $latex n \le 1$ ; $latex \sum_{x=1}^{\infty}(\frac{1}{x^n})$ diverges.