您可以通过增加递归限制来解决此问题,例如:
SetSystemOptions[“RecursionLimit” -> 10000]
或者您可以尝试优化代码,以避免出现递归错误。例如,您可以使用函数迭代而不是递归来计算y[r]。这样做可以避免递归深度的增加并提高代码效率。以下是一个可能的改进版本:
f[r, y] := (r^2*y)/(r - 1 - Log[r]); yIter[r_] := Block[{y0 = 0}, FixedPoint[(# /. y -> Function @@ {1 - Exp[-r #]}) &, y0, 50] ] rList = Range[0, 4, 4⁄999]; data = Table[{rList[[i]], f[rList[[i]], yIter[rList[[i]]]]}, {i, 1, 1000}]; ListPlot[data, PlotRange -> All, Frame -> True, Axes -> False, FrameLabel -> {“r”, “f”}, PlotStyle -> PointSize[Tiny]]