MathGroup Archive 2010

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

Search the Archive

Re: Pi day

  • To: mathgroup at
  • Subject: [mg108418] Re: Pi day
  • From: Daniel Lichtblau <danl at>
  • Date: Wed, 17 Mar 2010 04:38:58 -0500 (EST)

Ray Koopman wrote:
> The code I gave can certainly be speeded up, but right now I'm more 
> concerned about the algorithm. 'hi' is meant to be the smallest value 
> of the form s[[i]]/s[[j]] that is greater than Pi, and 'lo' is meant 
> to be the largest value of the form s[[i]]/s[[j]] that is less than 
> Pi. 'hi' is OK, but I wonder about 'lo'. 

I have not looked carefully at the code. The basic idea is smarter than 
I thought (more correctly, my understanding was stupider than necessary).

A variant would do an iteration over valid denominators. For each, find 
the integer numerator that gives the closest approximation to pi. Then 
walk in both directions (that is, increment and decrement) until you 
find a valid numerator, and see if either gives a result better than teh 
best found thus far.

Or only look at valid numerators (that is, those formed by permutations 
of the available digits), and do a binary search to get to the one 
giving a value closest to pi. For this one would need to sort the 
available values. not to onerous when there are only 9! or so.


  • Prev by Date: Re: Integration of InterpolatingFunction
  • Next by Date: InterpolatingFunction and NIntegrate
  • Previous by thread: Re: Pi day
  • Next by thread: Re: Pi day