Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98546
| From | Peter Pearson <pkpearson@nowhere.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Calulation in lim (1 + 1 /n) ^n when n -> infinite |
| Date | 2015-11-09 17:51 +0000 |
| Message-ID | <dac4p6Fq56qU1@mid.individual.net> (permalink) |
| References | <ea008366-9aa2-47e6-b4b7-69e5d447d408@googlegroups.com> |
On Mon, 9 Nov 2015 04:21:14 -0800 (PST), Salvatore DI DIO wrote: > > I was trying to show that this limit was 'e' > But when I try large numbers I get errors > > def lim(p): > return math.pow(1 + 1.0 / p , p) > >>>> lim(500000000) > 2.718281748862504 >>>> lim(900000000) > 2.7182820518605446 !!!! Python floats have close to 16 decimal digits of precision. When you compute 1+1/p with large p, the result will be close to 1, so digits of 1/p beyond the 16th place will be damaged by rounding. For p of 900000000, the first nearly-9 digits of 1/p are zero, so the first "significant" digit is the 10th, and beyond the 16th digit -- the 7th significant digit -- they're damaged, so you can only expect about 16-9 = 7 significant digits to be accurate. And as it turns out, 2.7182820518605446 is good to about 7 significant figures. It takes longer to explain than to see: roundoff limits you to ... (digits of p) + (good digits in the result) = 16 (approximately) -- To email me, substitute nowhere->runbox, invalid->com.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Calulation in lim (1 + 1 /n) ^n when n -> infinite Salvatore DI DIO <artyprog@gmail.com> - 2015-11-09 04:21 -0800
Re: Calulation in lim (1 + 1 /n) ^n when n -> infinite Chris Angelico <rosuav@gmail.com> - 2015-11-09 23:45 +1100
Re: Calulation in lim (1 + 1 /n) ^n when n -> infinite Salvatore DI DIO <artyprog@gmail.com> - 2015-11-09 07:13 -0800
Re: Calulation in lim (1 + 1 /n) ^n when n -> infinite Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-11-09 12:50 +0000
Re: Calulation in lim (1 + 1 /n) ^n when n -> infinite Salvatore DI DIO <artyprog@gmail.com> - 2015-11-09 07:13 -0800
Re: Calulation in lim (1 + 1 /n) ^n when n -> infinite Salvatore DI DIO <artyprog@gmail.com> - 2015-11-09 07:15 -0800
Re: Calulation in lim (1 + 1 /n) ^n when n -> infinite Peter Pearson <pkpearson@nowhere.invalid> - 2015-11-09 17:51 +0000
Re: Calulation in lim (1 + 1 /n) ^n when n -> infinite Salvatore DI DIO <artyprog@gmail.com> - 2015-11-10 00:26 -0800
csiph-web