Re: Bernoulli Numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg122633] Re: Bernoulli Numbers
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Fri, 4 Nov 2011 05:59:31 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <j8r9gv$3jd$1@smc.vnet.net> <201111030844.DAA15137@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
Much faster is: Clear[b] b[0] = 1; b[n_] := b[n] = -Sum[Binomial[n + 1, k]*b[k], {k, 0, n - 1}]/(n + 1) Array[b, 17, 0] // Timing {0.000679, {1, -(1/2), 1/6, 0, -(1/30), 0, 1/42, 0, -(1/30), 0, 5/66, 0, -(691/2730), 0, 7/6, 0, -(3617/510)}} whereas before, the timing was: Clear[b] b[0] = 1; b[n_] := -Sum[Binomial[n + 1, k]*b[k], {k, 0, n - 1}]/(n + 1) Array[b, 17, 0] // Timing {0.717417, {1, -(1/2), 1/6, 0, -(1/30), 0, 1/42, 0, -(1/30), 0, 5/66, 0, -(691/2730), 0, 7/6, 0, -(3617/510)}} Bobby On Thu, 03 Nov 2011 03:44:09 -0500, Dr. Wolfgang Hintze <weh at snafu.de> wrote: > Why not solve by hand for b[n] (and preferrably use lower case symbols > for your own ones), i.e. > > b[n_] := -Sum[Binomial[n + 1, k]*b[k], {k, 0, n - 1}]/(n + 1) > > and then calculate the values recursively in a table > b[0] = 1; > > Table[{n, b[n]}, {n, 0, 16}] > > {{0, 1}, {1, -(1/2)}, {2, 1/6}, {3, 0}, {4, -(1/30)}, > {5, 0}, {6, 1/42}, {7, 0}, {8, -(1/30)}, {9, 0}, > {10, 5/66}, {11, 0}, {12, -(691/2730)}, {13, 0}, > {14, 7/6}, {15, 0}, {16, -(3617/510)}} > > Regards, > Wolfgang > > "David Turner" <DTurner at faulkner.edu> schrieb im Newsbeitrag > news:j8r9gv$3jd$1 at smc.vnet.net... >> Hello, >> >> I wish to compute several Bernoulli numbers, say B0 through B20. The >> Bernoulli numbers are defined recursively by >> >> B0 = 1, and Solve[Sum[Binomial[n,k]*Bk,{k,0,n-1}]==0,Bn-1] for n > 1 >> >> I am trying to compute these numbers in some type of loop, and >> display them in a table. Any help is greatly appreciated. >> >> Thanks, >> >> David >> >> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >> _ _ _ >> >> This email and any files transmitted with it are confidential and >> intended solely for the use of the individual or entity to whom they >> are addressed. This message contains confidential information and is >> intended only for the individual named. If you are not the named >> addressee you should not dissem inate, distribute or copy this >> e-mail. Please notify the sender immediately by e-mail if you have >> received this e-mail by mistake and delete this e-mail from your >> system. If you are not the intended recipient you are notified that >> disclosing, copying, distributing or taking any action in reliance on >> the contents of this information is strictly prohibited. > > -- DrMajorBob at yahoo.com
- References:
- Re: Bernoulli Numbers
- From: "Dr. Wolfgang Hintze" <weh@snafu.de>
- Re: Bernoulli Numbers