Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6163

Re: Bernoulli Numbers

From DrMajorBob <btreat1@austin.rr.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Bernoulli Numbers
Date 2011-11-04 11:02 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j90gno$si6$1@smc.vnet.net> (permalink)
References <j8r9gv$3jd$1@smc.vnet.net> <201111030844.DAA15137@smc.vnet.net>

Show all headers | View raw


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@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@faulkner.edu> schrieb im Newsbeitrag
> news:j8r9gv$3jd$1@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@yahoo.com

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Bernoulli Numbers David Turner <DTurner@faulkner.edu> - 2011-11-02 11:28 +0000
  Re: Bernoulli Numbers "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-11-03 08:46 +0000
  Re: Bernoulli Numbers Simon <simonjtyler@gmail.com> - 2011-11-03 08:51 +0000
  Re: Bernoulli Numbers DrMajorBob <btreat1@austin.rr.com> - 2011-11-04 11:02 +0000
  Re: Bernoulli Numbers "Alexander Elkins" <alexander_elkins@hotmail.com> - 2011-11-04 11:04 +0000

csiph-web