# Finding the limit of the average of a sequence?

 Clear["Global*"]
G[s_] := Sort[DeleteDuplicates[Select[Flatten[Table[1/Round[(2^s)/m], {m, 1, 2^s}]],Between[#, {0, 1}] &]]]
f[x_] := Piecewise[{{Log[1/x], PrimeQ[1/x]}}, x]
Averagef[s_] := Averagef[s] = N[Mean[Table[Simplify[f[G[s][[x]]]], {x, 1, Length[G[s]]}]]]


I want to find values of Averagef[s_] for larger values of s.

The problem is I'm unable to calculate Averagef[s_] past s=16

How do we improve my code to calculate Averagef[s_] for larger values of s? Does the limit of Averagef[s_] exist as s approaches infinity?

• It might be easier if you define $f$ in terms of $m$ instead of $x = 1/m$. But it looks hard, because I'm not sure whether Mathematica can analyze (mathematically) the condition in the definition of $f$ — maybe there's someone here or at WRI who knows. You might have to do some of the mathematics yourself. Dec 28 '21 at 18:30
• Are you missing a Mean in the definition of Averagef`, or is it supposed to return a list of varying length? Dec 28 '21 at 18:34
• @MichaelE2 Oops. Fixed it. Dec 28 '21 at 18:36
• @MichaelE2 What does WRI stand for? Dec 28 '21 at 18:45
• Wolfram Research Inc., the maker of Mathematica. Dec 28 '21 at 20:19