Ugly e Math Stuff

I’m no math genius. I’d love to understand it all, and I appreciate the complexities, but I’m just the noob first-time player walking across a field in Call of Duty where I’m a target to all the more experienced players. In short: The study of compound interest eventually gives rise to the mathematical concept of e, also known as Euler’s number.

Like π, e is an irrational, transcendental number that has properties so compelling that it would qualify as the centerfold for the math geek’s version of Playboy.

The most important thing I know about e is that it’s often called Euler’s number, after Swiss mathematician Leonhard Euler. And the most important thing about that knowledge tidbit is knowing that “Euler” is pronounced “Oiler.”

e is a constant: 2.718282… It’s considered the sum of an infinite series, which means that you can keep making specific calculations long enough that the total eeks up to the value of e.

This concept plays into the notion of compound interest (covered in last week’s Lesson), because as you continue to compound and compound, you end up with the value 2.718282… Centuries ago, mathematicians discovered this effect and they haven’t shut up about it since.

The following code is a variation on the compound interest calculation presented last week. It’s a type of infinite series, where values keep getting larger but the result eventually settles on a specific number, e:

#include <stdio.h>
#include <math.h>

int main()
{
    long n;
    float p;

    for(n=1;n<100000;n+=1000)
    {
        p = pow( ( 1.0 + (1.0/n) ), n );
        printf("%f\n",p);
    }

    return(0);
}

The function on Line 11 of the code is similar to the compound interest function described in last week’s Lesson. The term variable t is missing (or assumed to be 1) and the rate is set to 1, so it’s not shown. Figure 1 illustrates how the math geeks write it (two ways).

Figure 1. Two different ways that the value of e is calculated.

The output is 100 lines long, and the first few lines jump the value pretty close to e:

2.000000
2.716925
2.717603
2.717829

As the value of variable n increases, the output gets closer:

2.718267
2.718268
2.718268
2.718268
2.718268

The C library function log() is the natural logarithm, which uses e as the base. The concept completely befuddles me, though I’ve used the log() function to realistically animate a bouncing ball. I’m sure the log() function has other uses that would delight the propeller heads.

Mathematically, if you take ee you get 15.154262. The natural logarithm of that value is e, which the following code proves:

#include <stdio.h>
#include <math.h>

int main()
{
    printf("e = %f\n",log(15.154262));

    return(0);
}

The log() function requires the math.h header file, included at Line 2. Here’s the output:

e = 2.718282

And that’s as far as I dare tread over the deep waters of mathematics.

3 thoughts on “Ugly e Math Stuff

  1. Logarithms shouldn’t befuddle you – the idea is quite simple. For example in the following
    102 = 100
    we know the values 10 and 2, and use them to calculate the result 100.
    But if you happen to know the values 10 and 100, then log10 (to use the C function name) gives you the “missing” value 2.

    (To round off the idea of calculating the missing value if you have the other two, if you have the 2 and the 100, you can calculate the 10 by taking the square root of 100. Basically, if you know any two values from an equation in the form xn = y you can work out the other.)

    For centuries logarithms were used to simplify arithmetic by reducing multiplication to addition, either using books of log tables or slide rules. The first pocket calculators in the 1970s were known rather quaintly as electronic slide rules. They can also be used to work out, for example, how long it will take to earn a specific amount at a specified interest rate.

  2. In my previous comment the 2 in 102 = 100 and the n in xn = y were supposed to be superscript, but it didn’t work out. Sorry!

    I think the HTML tags got stripped out – understandable I suppose.

    Think of them as 10^2 = 100 and x^n = y.

  3. Thanks, Chris. I’d love to figure all that out, and I had once when I was in school. I understand the simplicity, but at times I just toss up my hands and move on to the next puzzle.

Leave a Reply