Please check out Eric Roland trending 1 Billion is Tiny in an Alternate Universe (Intro to p-adic Numbers) #SoME2 on YouTube. This is a handy companion notebook to help you understand the key components in this fabulous video.
Visualization the limit of n102 as n goes infinity
Visualization the limit of as goes infinity
n
10
2
n
The highly efficient PowerMod function is based on theorems in number theory . It computes the last 100 digits for ridiculous large exponentials in a fraction of seconds .
In[]:=
data=Table[PowerMod[2,10^k,10^100],{k,1,100}];
The convenient way to generate a similar plot to that in the video is to set the the color of 0 to that of the background of the plot. Thus I choose white here.
In[]:=
cr={0->White}~Join~Thread[Range[1,9,1]->Array[ColorData[1],9]]
Out[]=
{0,1,2,3,4,5,6,7,8,9}
Combined the code to generate the beautiful conver
In[]:=
ArrayPlot[PadLeft[#,100,0]&@*IntegerDigits/@Table[PowerMod[2,10^k,10^100],{k,1,100}],ColorRules->cr]
Out[]=
Visualization the limit of n52 in base 5
Visualization the limit of in base 5
n
5
2
Use the same code with different parameters:
In[]:=
data=Table[PowerMod[2,5^k,10^100],{k,0,99}];
Convert the residues to base 5 and use the similar color scheme:
In[]:=
cr={0->White}~Join~Thread[Range[1,4,1]->Array[ColorData[1],4]]
Out[]=
{0,1,2,3,4}
Again use the ArrayPlot to visualize the convergent pattern
In[]:=
ArrayPlot[PadLeft[#,100,0]&/@IntegerDigits[data,5],ColorRules->cr]
Out[]=
A useful rational and p-adic conversion function
A useful rational and p-adic conversion function
I added an option to the following source code to terminate the computation quickly if we are not interested in finding the entire looping structure of the rational number in terms of p-adic representation. I will use the function to replicate other examples in the YouTube video
(*Sourcecodeisfromhttp://course1.winona.edu/eerrthum/UndergradResearch/p-adicContinuedFractions/index.htm*)
In[]:=
Clear[RationalTopAdic]
In[]:=
Options[RationalTopAdic]={"NumberOfDigits"->Infinity};
In[]:=
RationalTopAdic[x_?NumericQ,p_,OptionsPattern[]]:=Module[{fac,primes,powers,offset,ans={},re,relist={},count=0,nod},nod=OptionValue["NumberOfDigits"];fac=Transpose[FactorInteger[x*NextPrime[Max[x,p]]]];primes=fac[[1]];powers=fac[[2]];If[MemberQ[primes,p],offset=powers[[Position[primes,p][[1,1]]]],offset=0];re=x*p^(-offset);While[(Not[MemberQ[relist,re]]&&re≠0),relist=Append[relist,re];count++;If[nod===Infinity||nod>=count,ans=Append[ans,Mod[Numerator[re]*PowerMod[Denominator[re],-1,p],p,(1-p)/2]],Break[]];re=(re-Last[ans])/p];If[re0,{offset,ans,{}},{offset,Take[ans,Position[relist,re][[1,1]]-1],Drop[ans,Position[relist,re][[1,1]]-1]}]]
In[]:=
RationalTopAdic[x_List,p_,OptionsPattern[]]:=RationalTopAdic[#,p,"NumberOfDigits"->OptionValue["NumberOfDigits"]]&/@x
2N+7 divisible by a large power of 2
2
N
This can be visualize by the DiscretePlot function and counting the power of 2 from the result of FactorInteger function for some odd N. The first item from the FatorInteger list is what we are looking for because 2 is always the smallest prime for even number +7
2
N
In[]:=
DiscretePlot[FactorInteger[(2k-1)^2+7][[1,2]],{k,150},PlotRange->All]
Out[]=
Use the Newton method mentioned in the video to find the possible candidates
In[]:=
candidates=NestList#-&,1,8
#^2+7
2*#
Out[]=
1,-3,-,,,,-,,-
1
3
31
3
449
93
70529
41757
3615594751
2945079453
23820962743960351231
10648213811544751203
113126467792729861089136567110653207551
253650704494531566925735633658389780893
Take the first 50 digits from right. The result means that we start from and express the approximated 2-adic number
0
2
In[]:=
RationalTopAdic[Last@candidates,2,"NumberOfDigits"->50]
Out[]=
{0,{1,0,1,0,1,1,0,1,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,1,0,0,1,1,1,0,0,1,1,1,0,0,0,1,1,0,1,1,0,1,1,1,0,1,0,0},{}}
This number agrees with that in the video
In[]:=
FromDigits[Reverse[%[[2]]],2]
Out[]=
206036503412917
Indeed this number gives our +7 divisible by a large power of 2:
2
N
In[]:=
FactorInteger[%^2+7]
Kummer for Fibonacci
Kummer for Fibonacci
Eric’s paper on convergence of a subset Fibonacci number to sort of imaginary 2-adic number is very demanding and it outside the scope of this blog. Yet I happened to come across Kummer’s theorem when I tried to follow the instruction to solve a difficult problem in conjunction with generating function. Kummer’s theorem plays a vital role in p-adic related proof for this Fibonacci property mentioned in the video because Binet formula involves the number theoretic property of binomial coefficient.
which is true because there are only 3 trailing zeros at the end of this 1818 digit long number:
Concluding remark
Concluding remark
It is absolutely enjoyable to watch Eric’s masterpiece on this quite intriguing topic in advanced mathematics. Before this video I watched Fields medalist R Borcherds number theory lecture and he mentioned this concept in Berkeley Math 115. I suggest anyone interested in number theory takes time to slowly digest what is covered in both resources, meanwhile using WL to enhance the understanding with concrete computation.