# Casio hand calculator vs Mathematica at (1+1/n)^n

The CASIO fx-7400G calculator is very quick at doing $(1+1/1000000)^{1000000}$, giving an output of 2.718280469.

Mathematica (v7) takes over a minute, running on an Intel Core2 Duo processor, and its output is this:

With n=10000000, my patience ran out. The calculator is quick again with an output of 2.718281693.

Does anybody know why this happens?

-
My guess is that the calculator simply uses some $n$-th binomial approximation before things become too small for it, so even the first several dozen summands would still be very quick to run, while Mathematica is trying to give you an accurate result which require an immense amount of power to calculate. – Asaf Karagila Sep 21 '10 at 13:54
I agree with Asaf. Mathematica defaults to exact computation, not 10 digits. – Qiaochu Yuan Sep 21 '10 at 13:57
I agree, wolframalpha takes a long time as well. – Graviton Sep 21 '10 at 14:11
That's right. If I input N[(1+1/10000000)^10000000,10], the output is just as quick. – Weltschmerz Sep 21 '10 at 14:17
Um ... or you could just hit the e button ... – Anthony Mills Sep 21 '10 at 16:51

General purpose computer algebra systems, unlike most calculators, are able to perform both exact/symbolic computations (e.g. exact integer arithmetic) in addition to approximate numerical computations (e.g. floating point). Thus when you present the problem in exact terms - as you do above - they will preserve that form - so as not to lose any information. Thus your problem will be interpreted as a computation in exact rational arithmetic, i.e. raising a rational number to an integer power. If instead you desire a real approximation of the result then you must explicitly specify such, e.g. using N[...] in Mma. This is but one of the many complexities that arise when one passes from special-purpose computation systems (e.g. calculators) to general purpose computer algebra systems (speaking as one who has often tried to tackle less trivial such complexities while working as a developer of the Macsyma computer algebra system).

-

Try

N[1 + 1/100000000000000, 2000]^100000000000000


which makes Mma do the computation with floating point numbers (but using 2000 exact digits, waaaaay more that your calculator!) In my computer,

In[41]:= Timing[N[1 + 1/100000000000000, 2000]^100000000000000]

Out[41]= {0.001999,
2.71828182845903164395114517625107361345759538109318401368108700081263
8880450911203511655259489457817904923933478503365902065203002443715271
2825230612837327582882359132201752486932090411441742152459981748434424
6796125955942676709724311384945123182525138185474706841748184641523835
6399319640050121555981826495805200410019220302352025402844917823115708
4890277526840712036588689004850449217720498524694546241483265385120337
3036215908323704165098770345249059641531345794163630084215403881301114
0222776646139077637586730556318554208747513123989912904288599990729397
4105912301684777926066523131379164170616992617301710309080427339172694
8652209704120914116266089477162936814414049552884109177338585344418934
4664761359706737137907335308204793693031274512475102742160130609557028
0606249997104370287581131479088448270923696582800846475772654584603126
9574917252623375481387197279590503661010907784866738170370137382154502
5239391867955746777742097465819430570361920416259681558416618161699424
5237267230224583604177051168028000345047412788448526660107314695031108
5918243291907671190858585383905903649083888525646705126721235172922992
7474539583108858881111281802649615453982269311194004892438663488977893
2481678450112257387961011092938028584251024526367562391996230685117325
0436239706780584781622006285082275199325910403142256578320132681839729
1241283875634170613592405031777334496908146321259758762276254422018659
2501711558155518458153097538288499261588998555672920722850605105301158
3203321297849315979775985916474141976627081937753054953188751346134290
6581791976723248211158139510858187401773833843382750617470712252506403
3501718283248275223376526908879174360214195321187111170739858908536480
0084276450965142494861141929264441784847261049017482036450996057648280
0994695573343998546256052750841029336112669690421548936514156835398676
3390097789579643086512481978170502348966487726085752931492687574582562
2555386293362518511636564659786083245494967887013590756572099854766124
625831647757374695456737571}


takes 0.002 seconds.

-
Even Timing[((1 + 1/#)^#) &[N[10^20, 5000]]] takes only a blink of an eye on my (relatively slow) netbook. – J. M. Sep 21 '10 at 14:57
In fact, in these situations formatting the output to print it usually takes more time in Mma that actually computing it! – Mariano Suárez-Alvarez Sep 21 '10 at 15:01
If you want more digits you have to increase $n$ in $(1+1/n)^n$; your observation is that $n=100000000000000$ only gives you 14 correct digits. By the way, you are saying N[(1 + 1/10^14)^(10^14), 20] but I used N[(1 + 1/10^14), 20]^(10^14), which is different. – Mariano Suárez-Alvarez Sep 21 '10 at 22:40
@J.M.: there is no point in writing N[10^20, 5000], for 10^20 is always evaluated exactly. – Mariano Suárez-Alvarez Mar 7 '11 at 20:46

I think your calculator might use $$a^b = \exp(b\ln a)$$ together with precalculated $\exp$ and $\ln$ tables to speed things up.

I know I would =)

-