I am trying to use the Mod
function as follows.
Table[
Nest[Mod[2 #, 1] &, FractionalPart[Pi], n],
{n, 100}] // N
Giving the following result:
{0.283185,0.566371,0.132741,0.265482,0.530965,0.0619298,0.12386,0.247719,0.495439,0.990877,0.981755,0.963509,0.927018,0.854036,0.708073,0.416146,0.832291,0.664583,0.329165,0.658331,0.316661,0.633322,0.266645,0.533289,0.0665783,0.133157,0.266313,0.532626,0.0652523,0.130505,0.261009,0.522018,0.0440369,0.0880737,0.176147,0.352295,0.70459,0.40918,0.818359,0.636719,0.273438,0.546875,0.09375,0.1875,0.375,0.75,0.5,0.,0.,0.,0.,0.,-1.,-2.,-4.,-8.,-17.,-35.,-70.,-141.,-282.,-564.,-1129.,-2259.,-4518.,-9036.,-18072.,-36145.,-72290.,-144580.,-289161.,-578323.,-1.15665*10^6,-2.31329*10^6,-4.62658*10^6,-9.25317*10^6,-1.85063*10^7,-3.70127*10^7,-7.40254*10^7,-1.48051*10^8,-2.96101*10^8,-5.92203*10^8,-1.18441*10^9,-2.36881*10^9,-4.73762*10^9,-9.47525*10^9,-1.89505*10^10,-3.7901*10^10,-7.5802*10^10,-1.51604*10^11,-3.03208*10^11,-6.06416*10^11,-1.21283*10^12,-2.42566*10^12,-4.85133*10^12,-9.70265*10^12,-1.94053*10^13,-3.88106*10^13,-7.76212*10^13,-1.55242*10^14}
Now when I do the following
ReleaseHold[
Hold[Table[
Nest[Mod[2. #1, 1.] &,
FractionalPart[3.14159], n], {n, 100.}]]]
I get the following
{0.283185,0.566371,0.132741,0.265482,0.530965,0.0619298,0.12386,0.247719,0.495439,0.990877,0.981755,0.963509,0.927018,0.854036,0.708073,0.416146,0.832291,0.664583,0.329165,0.658331,0.316661,0.633322,0.266645,0.533289,0.0665783,0.133157,0.266313,0.532626,0.0652523,0.130505,0.261009,0.522018,0.0440369,0.0880737,0.176147,0.352295,0.70459,0.40918,0.818359,0.636719,0.273438,0.546875,0.09375,0.1875,0.375,0.75,0.5,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}```
Clearly something to do with working precision. But could you explain why this discrepancy ?
Table[Nest[...], {n, 100}]
expression is functionally equivalent toNestList[Mod[2#, 1]&, FractionalPart[Pi], 100]
. The only difference is the fact that the latter expression includes your starting value; if you really don’t want that, you can useRest@NestList[...]
. $\endgroup$Table[ Nest[Mod[2 #, 1] &, FractionalPart[Pi], n], {n, 100}] // N[#, 20] & // N
$\endgroup$