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


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

Re: How to count

From danl@wolfram.com
Newsgroups comp.soft-sys.math.mathematica
Subject Re: How to count
Date 2012-04-03 08:55 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jledt9$h4k$1@smc.vnet.net> (permalink)
References <jl14ig$l5e$1@smc.vnet.net> <jl3uuf$3kp$1@smc.vnet.net> <jl90l4$mpf$1@smc.vnet.net>

Show all headers | View raw


On Sunday, April 1, 2012 2:38:12 AM UTC-5, Costa Bravo wrote:
> Daniel Lichtblau Wolfram Research
> 
> > bottom = 100000;
> > Timing[bb = Table[Ceiling[Exp[LogGamma[N[n+1,n]]/2]],
> >    {n,bottom,10*bottom,bottom}];]
> >
> > Out[16]= {671.196962, Null}
> 
> My computer needs more time
>      {1256.916, Null}
> 
> Let's test a better solution
> 
> n = 100000;
> {Timing[lg2 = Exp[LogGamma[N[n + 1, n]]/2];], Precision[lg2]}
> {Timing[lg2 = N[Exp[LogGamma[n + 1]/2], n];], Precision[lg2]}
> {Timing[lg2 = Exp[N[LogGamma[n + 1]/2, n]];], Precision[lg2]}
> 
> {{9.048, Null}, 556568.58}
> 
> {{3.338, Null}, 100000.}
> 
> {{0.593, Null}, 99994.11}    (* !!! *)
> 
> surprising result for n = 1 000 000
> 
> n = 1000000;
> {Timing[lg2 = Exp[LogGamma[N[n + 1, n]]/2];], Precision[lg2]}
> {Timing[lg2 = N[Exp[LogGamma[n + 1]/2], n];], Precision[lg2]}
> {Timing[lg2 = Exp[N[LogGamma[n + 1]/2, n]];], Precision[lg2]}
> 
> {{218.557, Null}, 6.5657032*10^6}
> 
> {{217.528, Null}, 1.*10^6}  (* !!! *)
> 
> {{27.877, Null}, 999993.19}
> 
> The new version of the original expression
> 
> bottom = 10^5;
> Timing[bb1 =
>     Table[Ceiling[Exp[N[LogGamma[n + 1]/2, n]]], {n, bottom, 10*bottom,
>        bottom}];]
> 
> {126.034, Null}
> 
> 10 times faster !!
> 
> --
>    Costa

Nice ketch.

Daniel Lichtblau
Wolfram Research

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


Thread

How to count Artur <grafix@csl.pl> - 2012-03-29 07:56 +0000
  Re: How to count Costa Bravo <q13a27tt@aol.com> - 2012-03-30 09:37 +0000
  Re: How to count danl@wolfram.com - 2012-03-30 09:38 +0000
    Re: How to count Costa Bravo <q13a27tt@aol.com> - 2012-04-01 07:38 +0000
      Re: How to count danl@wolfram.com - 2012-04-03 08:55 +0000

csiph-web