Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to count

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125760] Re: How to count
  • From: Costa Bravo <q13a27tt at aol.com>
  • Date: Sun, 1 Apr 2012 03:36:30 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jl14ig$l5e$1@smc.vnet.net> <jl3uuf$3kp$1@smc.vnet.net>

Daniel Lichtblau Wolfram Research   danl at wolfram.com wrote:

> 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



  • Prev by Date: Biokmod 5.02 ( a toolbox for biokinetic modeling, including ICRP models) is available
  • Next by Date: Re: solve trig equations
  • Previous by thread: how to make formatted output with Grid and Print?
  • Next by thread: Re: How to count