# Understanding FixedPoint

I understand that

FixedPoint[(# + 2/# )/2 &, 1.]


can be written

x[0] = 1; x[1] = 2;
x[k_] := N@(x[k - 1] + x[1]/x[k - 1])/2
x@5


but I don't understand how to interpret

CompositeP[n_Integer] := FixedPoint[n + PrimePi[#] + 1 &, n] - n


mathematically. How could it be rewritten using a recurrence relation? How would it be written in standard mathematical notation?

• \begin{align}x_0&=n\\x_{k+1}&=π(x_k)+n+1\end{align} May 9, 2015 at 11:25
• @Guesswhoitis. great! so simple! thanks :) May 9, 2015 at 11:28

Just to document what @Guesswhoitis. said in coments,

\begin{align}x_0&=n\\x_{k+1}&=π(x_k)+n+1\end{align}

which can be written

CompositeA[n_Integer] := FixedPoint[n + PrimePi[#] + 1 &, n]


or

rr = 10^2; x[0] = 1; x[1] = rr;
x[k_] := PrimePi[x[k - 1]] + x[1] + 1
x@5


On a different note, the same goal can be accomplised with

CompositeB[a_, r_] := 1 + a + Fold[PrimePi[a + #1 + 1] &, -1, Range[r]]


where

comp[a_] := 1 +a +Fold[PrimePi[a + #1 + 1] &, -1, Range[Floor[Log[a]] + 4]]


seems to do the trick, where Floor[Log[a]] + 4 is a rough (over) guess at number of iterations to make.

• I think you should put more attention to wording. Those functions are not the same. Arguments provided for them are different things either. The only thing which is the same is the goal. Which still is arguable since in FixedPoint you don't have to know a priori how many iterations to make.
– Kuba
May 9, 2015 at 14:16
• @Kuba ok, will update May 9, 2015 at 14:39