Version 3 of e

Updated 2004-09-23 15:45:01

Another irrational number. Available in expr as exp(1).

base of natural logarithms; useful since d/dx(e^x) = e^x.

And Integral(1/x) = ln(x) Integral(1/x) from 1 to e is ln(e) = 1.

2.718281828459... (see http://mathworld.wolfram.com/e.html ) Note it does not recur, despite repeating 1828 twice in the first 10 digits.

A spigot algorithm for calculating e:

# spigot algorithm for E from /*[email protected]*/ #in http://www1.physik.tu-muenchen.de/~gammel/matpack/html/Mathematics/Pi.html #int a3302,b=3301,*c=a,d,e,f;main(){for(e=b;--e;*c++=1);*c=2; #for(d=2001;d--;printf("%05d",f))for(c=a,e=b;e;f/=e--){f+=*c*1e5;*c++=f%e;}} # translated into Tcl:

   proc calce {} {
        list a
        set b 3301;        set c 0; set f 0

        for {set e [expr $b-1]} {$e>0} {incr e -1} {  lappend a 1 } ;# fill array with 1 for(e=b;--e;*c++=1);
        lappend a 2 ;#*c=2;
        puts "Should be e =\n2.71828182845904523536028747135266249775724709369995... "
        for {set d 2001} {$d>0 } {puts -nonewline [format "%.5i" [expr int($f)] ] } { ;#for(d=2001;d--;printf("%05d",f))
                incr d -1
                for {set c 0; set e $b} {$e>0} {flush stdout} {;# for(c=a,e=b;e;f/=e--){f+=*c*1e5;*c++=f%e;}
                        set f [expr int($f + [lindex $a $c]*100000)]  ;#f+=*c*1e5;
                        lset a $c [expr round(fmod($f,$e))];# *c = f%e
                        incr c ;# c++
                        set f [expr int($f/$e)] ;# f/=e
                        incr e -1 ;#e--
                }
        }
   } 
   calce


Category Mathematics