Hmmm....
Calculating n^k is easy enough by multiplying n by itself k times, or you could take the antilog of k*log(n). And n! is easier, as it builds on (n-1)!, so you don't even have to start from scratch with each term.
The numbers get big as n gets large, but the factorials increase so greatly compared to the powers that only a few terms are needed.
DEFDBL A-Z
FOR k = 1 TO 10
PRINT "k ="; k
t = 0
term = 1: f = 1
FOR n = 1 TO 44
f = f * n
term = n ^ k / f
t = t + term
PRINT USING "## ####.######### ####.########"; n; term; t
NEXT
PRINT k; t;
IF k = 1 THEN save = t: ELSE PRINT INT(t / save + .5);
PRINT
DO: LOOP UNTIL INKEY$ > ""
NEXT
Some results:
k = 1
n nth term partial total
1 1.000000000 1.00000000
2 1.000000000 2.00000000
3 0.500000000 2.50000000
4 0.166666667 2.66666667
5 0.041666667 2.70833333
6 0.008333333 2.71666667
7 0.001388889 2.71805556
8 0.000198413 2.71825397
9 0.000024802 2.71827877
10 0.000002756 2.71828153
11 0.000000276 2.71828180
12 0.000000025 2.71828183
13 0.000000002 2.71828183
14 0.000000000 2.71828183
So, for k=1, it seems to converge to e.
k = 2
1 1.000000000 1.00000000
2 2.000000000 3.00000000
3 1.500000000 4.50000000
4 0.666666667 5.16666667
5 0.208333333 5.37500000
6 0.050000000 5.42500000
7 0.009722222 5.43472222
8 0.001587302 5.43630952
9 0.000223214 5.43653274
10 0.000027557 5.43656030
11 0.000003031 5.43656333
12 0.000000301 5.43656363
13 0.000000027 5.43656365
14 0.000000002 5.43656366
15 0.000000000 5.43656366
So, for k=2, it seems to converge to 2e.
k = 3
1 1.000000000 1.00000000
2 4.000000000 5.00000000
3 4.500000000 9.50000000
4 2.666666667 12.16666667
5 1.041666667 13.20833333
6 0.300000000 13.50833333
7 0.068055556 13.57638889
8 0.012698413 13.58908730
9 0.002008929 13.59109623
10 0.000275573 13.59137180
11 0.000033344 13.59140515
12 0.000003608 13.59140876
13 0.000000353 13.59140911
14 0.000000031 13.59140914
15 0.000000003 13.59140914
16 0.000000000 13.59140914
At k=3, we now have 5e.
k = 4
1 1.000000000 1.00000000
2 8.000000000 9.00000000
3 13.500000000 22.50000000
4 10.666666667 33.16666667
5 5.208333333 38.37500000
6 1.800000000 40.17500000
7 0.476388889 40.65138889
8 0.101587302 40.75297619
9 0.018080357 40.77105655
10 0.002755732 40.77381228
11 0.000366788 40.77417907
12 0.000043290 40.77422236
13 0.000004587 40.77422694
14 0.000000441 40.77422738
15 0.000000039 40.77422742
16 0.000000003 40.77422743
17 0.000000000 40.77422743
Now, at k=4, it seems we have 15e. There go our hopes of getting some sequence of Fibonacci multiples of e.
k = 5
1 1.000000000 1.00000000
2 16.000000000 17.00000000
3 40.500000000 57.50000000
4 42.666666667 100.16666667
5 26.041666667 126.20833333
6 10.800000000 137.00833333
7 3.334722222 140.34305556
8 0.812698413 141.15575397
9 0.162723214 141.31847718
10 0.027557319 141.34603450
11 0.004034667 141.35006917
12 0.000519481 141.35058865
13 0.000059626 141.35064828
14 0.000006169 141.35065444
15 0.000000581 141.35065503
16 0.000000050 141.35065508
17 0.000000004 141.35065508
18 0.000000000 141.35065508
The total is 52e.
Cutting to the chase, commenting out the individual terms, and getting the final results of each k:
k sum multiple of e
1 2.718281828459046 1
2 5.436563656918090 2
3 13.59140914229523 5
4 40.77422742688568 15
5 141.3506550798703 52
6 551.8112111771861 203
7 2383.933163558582 877
8 11253.68676982045 4140
9 57483.50582642343 21147
10 315252.7350555378 115975
Looking up the sequence 1, 2, 5, 15, 52, 203, 877 in Sloane's On-line Encyclopedia of Integer sequences leads us to "Bell or exponential numbers: ways of placing n labeled balls into n indistinguishable boxes." So if you have a way of computing the Bell numbers, you can multiply e by the Bell numbers to get these sums.
But the ways of getting the Bell numbers look as complicated, or more so, than the computations in this program. Of course, you could start with a list of the Bell numbers and just multiply by e.
In fact, this could be one way of calculating the Bell numbers:
1 2.718281828459046 1
2 5.43656365691809 2
3 13.59140914229523 5
4 40.77422742688568 15
5 141.3506550798703 52
6 551.8112111771861 203
7 2383.933163558582 877
8 11253.68676982045 4140
9 57483.50582642343 21147
10 315252.7350555378 115975
11 1844544.500337454 678570
12 11453744.15754954 4213597
13 75145370.75508085 27644437
14 518918158.0577521 190899322
15 3759271082.385662 1382958545
16 28487979957.85786 10480142147
17 225250069805.8378 82864869804
18 1854076987795.393 682076806159
19 15855037146092.58 5832742205057
20 140600839423552 51724158235372
21 1290829992142583 474869816156751
22 1.225052349785174D+16 4506715738447322
Only the limitations on the accuracy of this particular programming language make the last Bell number approximation off by 1 in the units position.
|
Posted by Charlie
on 2008-02-19 12:42:02 |