Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Re: functions

Selwyn Hollis wrote:
> This is a pretty wild idea, but how about the following as a criterion
> for deeming a single-precision floating-point number between 0 and 1 to
> be "irrational": It's irrational if its base-10 form contains all 10
> digits, more precisely, if
>    IrrationalQ[x_] := Length[Union[IntegerDigits[Round[10^16*x]]]] == 10
> returns True. Then
>    grph = Plot[If[IrrationalQ[x], x, 0], {x, 0, 1}, PlotPoints -> 100]
> draws a graph that, with a little imagination, suggests what the graph
> of
> If[x is irrational, x, 0] could look like.
> Still better is
>    Show[Graphics[{AbsolutePointSize[1.5], Point[#]} & /@
>           (grph/.Graphics[{{Line[z_]}}, ___] -> z)]]
> This is all nonsense, of course, but fun nonetheless.
> Experiments show that IrrationalQ[Random[]] returns True with
> probability roughly 0.07. (Anybody have a clue why?)
> -----
> Selwyn Hollis
> [...]

As to that experimental probability...

If you ignore the case where the leading digit is zero and disappears,
the probability is modelled as follows.

Let p[j] denote the probability that the first j digits contain all 10
digits (so obviously p[j]=0 for j<10).

We have

p[10] = Product[j/10, {j,1,9}];

Now p[11] = p[10] + probability that we need exactly 11 digits to get
all 10 possibilities. This means exactly one of the first ten digits
replicates an earlier digit. This arises if the second digit replicates
the first (probability 1/10), or the third replicates the second or
first (probability 2/10), etc. In Mathematica this would be given by

Sum[k[1]/10,{k[1],9}] * p[10]

We need exactly 12 digits if exactly two of the first eleven digits
replicate earlier digits. This is given by

Sum[k[1]/10*k[2]/10, {k[1],9}, {k[2],k[1],9}] * p[10]

In general we have:

productsum[j_Integer] := Module[
  {k, vars, prod, iters},
  vars = Array[k,j-10];
  k[0] = 1;
  prod = Apply[Times,vars]/10^(j-10);
  iters = Map[{#,#[[0]][#[[1]]-1],9}&,vars];

(I'm sure this is not the cleanest way to code this).

p[j_Integer /; j>10] := p[j-1] + productsum[j]*p[10]

In[59]:= InputForm[p16 = p[16]]
Out[59]//InputForm= 10985907933/156250000000

In[60]:= N[p16]
Out[60]= 0.0703098

This pretty well replicates your experimental result.

By the way, those random decimals are double precision floats, not

Daniel Lichtblau
Wolfram Research

  • References:
    • functions
      • From:
    • Re: functions
      • From: Selwyn Hollis <>
  • Prev by Date: suppressing evaluation/simplification in Integrate
  • Next by Date: Re: Re: typesetting fractions
  • Previous by thread: Re: functions
  • Next by thread: Re: functions