Recently Stephen Wolfram and my friend and lab head, neurosurgeon and computer scientist Jeff Arle, were talking about Carl Sagan's idea (see his novel Contact) that a message could be embedded in a transcendental number, and Stephen said, "Let's write a program to find a number sequence in the sequence of any given number." Jeff said it took him just a minute or two (mine below took over an hour :-( but I bet he had written this function before :-).

You recall a transcendental number is a number that is irrational in any base and therefore has an infinite sequence. Since I see nothing that can be parameterized in a transcendental number, I don't see how anyone, even God (in this case the deistic creator or source of the universe), could embed a message in a transcendental number. On the other hand, you could specify a start location in any transcendental number for any message of any length, since any transcendental number contains all possible number sequences.

Thus the sequence of any approximation to Pi is contained somewhere in E, and vice versa. The following is my program to find any number sequence in any other sequence.

Clear@findSequence;

findSequence[sequence_?NumericQ,sourceNumber_,maxDigits_Integer,base_Integer:10]:=

Module[

{stringSequence=StringReplace[ToString@sequence,"."->""],

numberDigitSequence,partitionLength,partitionedNumber,

sourceSequence={}(*initialize sourceSequence*),

startPositionOfSequence=1,

targetSequence,targetSequenceLength},

targetSequenceLength=StringLength@stringSequence;

targetSequence=RealDigits@ToExpression@stringSequence//First;

Print@targetSequence;

numberDigitSequence=N[sourceNumber,maxDigits]//RealDigits//First;

partitionedNumber=Partition[numberDigitSequence,targetSequenceLength,1];

(* The length of the partitioned sequence is the number of partitions against which to try to match the target sequence. startOfSequence is the Position in the source sequence of the first digit of the subsequence being matched. Note using While means only the first match is found if there are more than one. *)

While[startPositionOfSequence<=Length@partitionedNumber&&sourceSequence=!=targetSequence,sourceSequence=partitionedNumber[[startPositionOfSequence]];startPositionOfSequence++];

If[sourceSequence==targetSequence,StringForm["Sequence starts at position ``.",startPositionOfSequence-1 (*subtract 1 since first comparison is between empty List {} and targetSequence*)],"Sequence not found."]

]

In[151]:= Timing@findSequence[3.14159, E, 10000000]

During evaluation of In[151]:= {3,1,4,1,5,9}

Out[151]= {9.406860, StringForm[

"Sequence starts at position ``.", 1436936]}

I thought Contact was a fun read and even better movie, but IMHO The Demon-Haunted World should be required reading for every scientist.

You recall a transcendental number is a number that is irrational in any base and therefore has an infinite sequence. Since I see nothing that can be parameterized in a transcendental number, I don't see how anyone, even God (in this case the deistic creator or source of the universe), could embed a message in a transcendental number. On the other hand, you could specify a start location in any transcendental number for any message of any length, since any transcendental number contains all possible number sequences.

Thus the sequence of any approximation to Pi is contained somewhere in E, and vice versa. The following is my program to find any number sequence in any other sequence.

Clear@findSequence;

findSequence[sequence_?NumericQ,sourceNumber_,maxDigits_Integer,base_Integer:10]:=

Module[

{stringSequence=StringReplace[ToString@sequence,"."->""],

numberDigitSequence,partitionLength,partitionedNumber,

sourceSequence={}(*initialize sourceSequence*),

startPositionOfSequence=1,

targetSequence,targetSequenceLength},

targetSequenceLength=StringLength@stringSequence;

targetSequence=RealDigits@ToExpression@stringSequence//First;

Print@targetSequence;

numberDigitSequence=N[sourceNumber,maxDigits]//RealDigits//First;

partitionedNumber=Partition[numberDigitSequence,targetSequenceLength,1];

(* The length of the partitioned sequence is the number of partitions against which to try to match the target sequence. startOfSequence is the Position in the source sequence of the first digit of the subsequence being matched. Note using While means only the first match is found if there are more than one. *)

While[startPositionOfSequence<=Length@partitionedNumber&&sourceSequence=!=targetSequence,sourceSequence=partitionedNumber[[startPositionOfSequence]];startPositionOfSequence++];

If[sourceSequence==targetSequence,StringForm["Sequence starts at position ``.",startPositionOfSequence-1 (*subtract 1 since first comparison is between empty List {} and targetSequence*)],"Sequence not found."]

]

In[151]:= Timing@findSequence[3.14159, E, 10000000]

During evaluation of In[151]:= {3,1,4,1,5,9}

Out[151]= {9.406860, StringForm[

"Sequence starts at position ``.", 1436936]}

I thought Contact was a fun read and even better movie, but IMHO The Demon-Haunted World should be required reading for every scientist.