How to increase the number of decimal places for this code?

How do I increase the number of decimal places for

f1 = Map[Flatten@*First]@MeshPrimitives[#, 1] &;
f2 = Flatten[Flatten[f1@CantorMesh[13]]];
f[x_] := x^(1/5)
N[Total[f@f2]/Length[f2], 10]


I get six decimal places instead of 10.

0.804028


How do we fix this?

We can write a new cantormesh function that uses exact numbers instead of floating-point approximations:

cantormesh[0] = {{0, 1}};
cantormesh[n_Integer?Positive] := cantormesh[n] =
Join @@ ({{#[[1]],(2#[[1]]+#[[2]])/3},{(#[[1]]+2#[[2]])/3,#[[2]]}} & /@
cantormesh[n-1])


Now the result is exact:

f2 = Flatten[cantormesh[13]];
f[x_] = x^(1/5);
Z = Total[f@f2]/Length[f2]
(*    long output    *)


N[Z, 30]

• Here is a nonrecursive version: cantormesh[n_Integer?NonNegative] := Nest[Replace[#, {x_?NumberQ, y_?NumberQ} :> Apply[Sequence, Partition[Subdivide[x, y, 3], 2]], 1] &, {{0, 1}}, n]. As for the OP's computation itself: With[{c = Flatten[N[cantormesh[13], 30]]}, Mean[c^(1/5)]]. Mar 30, 2020 at 0:50