RecurrenceTable[eqns,expr,{n,nmax}]
以求解递归方程 eqns 为基础,产生一组关于连续 n 的 expr 的值的列表.
RecurrenceTable[eqns,expr,nspec]
在 nspec 指定的 n 值范围上,产生一组 expr 的值.
RecurrenceTable[eqns,expr,{n1,…},{n2,…},…]
为连续的 n1,n2,… 产生 expr 的数组值.
RecurrenceTable
RecurrenceTable[eqns,expr,{n,nmax}]
以求解递归方程 eqns 为基础,产生一组关于连续 n 的 expr 的值的列表.
RecurrenceTable[eqns,expr,nspec]
在 nspec 指定的 n 值范围上,产生一组 expr 的值.
RecurrenceTable[eqns,expr,{n1,…},{n2,…},…]
为连续的 n1,n2,… 产生 expr 的数组值.
更多信息和选项
- eqns 必须是递归方程,它的解可以通过给出的初始条件或边界值确定.
- eqns 可以涉及形式 a[n+i] 的对象,其中 i 是任意固定整数.
- 范围 nspec 可以使用 Table 中的任何形式.
- 可以给出下列选项:
-
DependentVariables Automatic 所有独立变量的列表 Method Automatic 使用的方法 WorkingPrecision Automatic 内部计算使用的精度 - 在 DependentVariables->Automatic 下,RecurrenceTable 确定解析给出方程的独立变量.
- 在 WorkingPrecision->Automatic 下,精确计算有精确输入的结果,并且对于不精确的输入,精度根据每次迭代相确定.
- 在 WorkingPrecision->p 下,一个固定精度 p 用于所有迭代中.
- RecurrenceTable[u[t]sys,resp,{t,tmin,tmax}] 可用于解离散时间模型,其中 sys 可以是 TransferFunctionModel 或 StateSpaceModel,响应函数 resp 可为以下形式: »
-
"StateResponse" sys 对输入
的状态响应"OutputResponse" sys 对输入
的输出响应
范例
打开所有单元 关闭所有单元基本范例 (4)
RecurrenceTable[{a[n + 1] == 3a[n], a[1] == 7}, a, {n, 1, 10}]RecurrenceTable[{a[n] == a[n - 1] + a[n - 2], a[1] == 1, a[2] == 1}, a,
{n, 10}]Table[Fibonacci[n], {n, 10}]RecurrenceTable[{x[n + 1] == 0.7x[n] + y[n],
y[n + 1] == -0.7989995 + x[n] ^ 2, x[0] == 0.142857, y[0] == 0.33}, {x, y}, {n, 1, 2500}]//ShortListPlot[%, PlotRange -> All]RecurrenceTable[{s1[n, k] == s1[n - 1, k - 1] - (n - 1)s1[n - 1, k],
s1[0, k] == KroneckerDelta[k]}, s1, {n, 0, 6}, {k, 0, 4}]//GridTable[StirlingS1[n, k], {n, 0, 6}, {k, 0, 4}]//Grid范围 (12)
普通微分方程 (6)
RecurrenceTable[{a[n + 2] == 3n a[n + 1] + 5a[n], a[1] == 1, a[2] == 1}, a, {n, 1, 10}]RecurrenceTable[{a[n] == 1.3a[n - 2] ^ 2 + 5.2a[n - 1], a[1] == 1, a[2] == 2}, a, {n, 1, 6}]RecurrenceTable[{2 x[n + 1] + Mod[n, 5] ^ 2 y[n] == n, 5 x[n] - y[n + 1] == 7, x[1] == a, y[1] == b}, {x, y}, {n, 1, 3}]//TogetherRecurrenceTable[{2 x[n + 1] + Mod[n, 5] ^ 2 y[n] == n, 5 x[n] - y[n + 1] == 7, x[1] == a, y[1] == b}, x, {n, 1, 3}, DependentVariables -> {x, y}] // TogetherRecurrenceTable[{x[n + 1] == (7/2)x[n](1 - x[n]), x[0] == (1/3)}, x, {n, 10}]RecurrenceTable[{x[n + 1] == (7/2)x[n](1 - x[n]), x[0] == N[(1/3), 20]}, x, {n, 10}]ListPlot[Map[Precision, %]]RecurrenceTable[{x[n + 1] == (7/2)x[n](1 - x[n]), x[0] == (1/3)}, x, {n, 10}, WorkingPrecision -> 20]RecurrenceTable[{x[n + 1] == (7/2)x[n](1 - x[n]), x[0] == (1/3)}, x, {n, 10}, WorkingPrecision -> MachinePrecision]Grid[Partition[Map[ListPlot[#, DataRange -> {0, 1}, PlotStyle -> PointSize[0.01]]&, RecurrenceTable[{x[n + 1] == .9 Sin[π x[n]], x[0] == N[Range[0, 1000] / 1000]}, x, {n, 0, 8}]], 3]]Map[MatrixForm, RecurrenceTable[{m[k + 1] == m[k].(| | |
| -- | -- |
| .1 | 1 |
| 0 | .1 |).m[k], m[0] == (| | |
| - | -- |
| 0 | -1 |
| 1 | 0 |)}, m, {k, 3}]]偏微分方程 (2)
RecurrenceTable[{binomial[n, k] == binomial[n - 1, k] + binomial[n - 1, k - 1], binomial[0, k] == KroneckerDelta[k]}, binomial, {n, 0, 8}, {k, 0, 8}]//GridRecurrenceTable[{f[n, k] == f[n - 1, k] ^ 2 + n ^ 2f[n - 1, k - 1], f[0, k] == 3k + 1.}, f, {n, 0, 20}, {k, 0, 20}];MatrixPlot[Log[1 + Abs[%]]]差分-代数方程 (1)
sol1 = RecurrenceTable[{y[n + 1] + z[n + 1] == y[n] - 3z[n] + 7, y[n] + 2z[n] == 1, y[0] == 1 / 2, z[0] == 1 / 4}, {y, z}, {n, 0, 4}]//Quiet与 RSolve 给出的符号解比较:
RSolve[{y[n + 1] + z[n + 1] == y[n] - 3z[n] + 7, y[n] + 2z[n] == 1, y[0] == 1 / 2, z[0] == 1 / 4}, {y, z}, n]sol2 = Table[{y[n], z[n]} /. %[[1]], {n, 0, 4}]系统模型 (3)
sr = RecurrenceTable[Sin[t] -> StateSpaceModel[{{{0, 1}, {-0.5, 1.5}}, {{0}, {1}}, {{0, 1}}, {{0}}}, SamplingPeriod -> 1,
SystemsModelLabels -> None], "StateResponse", {t, 0, 15}]ListStepPlot[sr, DataRange -> {0, 15}]or = RecurrenceTable[Sin[t] -> StateSpaceModel[{{{0, 1}, {-0.5, 1.5}}, {{0}, {1}}, {{0, 1}}, {{0}}}, SamplingPeriod -> 1,
SystemsModelLabels -> None], "OutputResponse", {t, 0, 15}]ListStepPlot[or, DataRange -> {0, 15}]sr = RecurrenceTable[{Sin[t] -> StateSpaceModel[{{{0.9418, 0.2462}, {-0.2462, 0.3262}}, {{0.1958}, {-0.0291}}, {{2, 1}}, {{0}}},
SamplingPeriod -> 0.2, SystemsModelLabels -> None], {1, -1}}, "StateResponse", {t, 0, 10}]ListStepPlot[sr, DataRange -> {0, 10 0.2}]or = RecurrenceTable[{Sin[k], Cos[k]} -> TransferFunctionModel[{{{z, -0.1 + z}, {1, 4}},
{{-0.5 + z, 0.5 + z}, {-0.5 + z, 0.5 + z}}},
z, SamplingPeriod -> 0.1], "OutputResponse", {k, 0, 3}]ListStepPlot[or, DataRange -> {0, 3 0.1}]推广和延伸 (3)
RecurrenceTable[{a[n] == a[n - 1] + a[n - 2], a[1] == 1, a[2] == 1}, a, {n, 1, 15}]RecurrenceTable[{a[n] == a[n - 1] + a[n - 2], a[1] == 1, a[2] == 1}, a, {n, 1, 15, 2}]Timing[First[RecurrenceTable[{x[n + 1] == π Sin[π x[n]], x[0] == .1}, x, {n, 10 ^ 6, 10 ^ 6}]]]Timing[Last[RecurrenceTable[{x[n + 1] == π Sin[π x[n]], x[0] == .1}, x, {n, 10 ^ 6}]]]RecurrenceTable[{x[n + 1] == π Sin[π x[n]], x[0] == Range[0, 1, .1]}, x, {n, 5}]选项 (3)
DependentVariables (1)
当您仅需要保存某些值时,用 DependentVariables 指定变量:
RecurrenceTable[{x[n + 2] == y[n], y[n + 1] == -x[n], x[0] == 1, x[1] == 0, y[0] == 0}, x, {n, 0, 3}, DependentVariables -> {x, y}]RecurrenceTable[{x[n + 2] == y[n], y[n + 1] == -x[n], x[0] == 1, x[1] == 0, y[0] == 0}, y, {n, 0, 3}, DependentVariables -> {x, y}]RecurrenceTable[{x[n + 2] == y[n], y[n + 1] == -x[n], x[0] == 1, x[1] == 0, y[0] == 0}, {y, x}, {n, 0, 3}, DependentVariables -> {x, y}]Method (1)
用 Method->{Compiled->False} 避免使用 Wolfram 语言编译:
m = 10 ^ 6;
reqn = {x[n + 1] == Nest[(4 #(1 - #))&, x[n], 2], x[0] == .314}Timing[Last[compiled = RecurrenceTable[reqn, x, {n, m}]]]Timing[Last[justrun = RecurrenceTable[reqn, x, {n, m}, Method -> {Compiled -> False}]]]ListPlot[Take[Abs[compiled - justrun], 50], PlotRange -> All]WorkingPrecision (1)
对于更快速迭代,用 WorkingPrecision->MachinePrecision:
reqn = {x[n + 1] == (9 / 5)If[x[n] < 1 / 2, x[n], 1 - x[n]], x[0] == 1 / 3};Timing[Mean[RecurrenceTable[reqn, x, {n, 10 ^ 6}, WorkingPrecision -> MachinePrecision]]]对于较慢速迭代,用 WorkingPrecision->p,但迭代的精度更高:
Timing[Mean[RecurrenceTable[reqn, x, {n, 10 ^ 6}, WorkingPrecision -> 50]]]Timing[Mean[RecurrenceTable[reqn, x, {n, 10 ^ 4}]];]应用 (6)
对数方程 (1)
随机数产生 (1)
RecurrenceTable[{x[n + 1] == Abs[Mod[100Log[x[n]], 1]], x[0] == 0.1}, x, {n, 0, 4}]RecurrenceTable[{x[n + 1] == Abs[Mod[100Log[x[n]], 1]], x[0] == 0.1}, x, {n, 1, 1000}]//ListPlott = RecurrenceTable[{x[n + 1] == Abs[Mod[100Log[x[n]], 1]], x[0] == 0.1}, x, {n, 1, 10 ^ 5}];({Mean[#1], Variance[#1], Skewness[#1], Kurtosis[#1]} & )[t]N[({Mean[#1], Variance[#1], Skewness[#1], Kurtosis[#1]} & )[UniformDistribution[{0, 1}]]]兔形 (1)
c = -0.122561 + 0.744862I;初始条件,在矩形的每个方向有 250 个点,其中矩形有角度
和
:
zinit = Table[a + I b, {a, -1.3, 1.3, 2.6 / 249}, {b, -1.3, 1.3, 2.6 / 249}];Timing[iterates = RecurrenceTable[{z[k + 1] == z[k] ^ 2 + c, z[0] == zinit}, z, {k, 0, 20}];]用 ArrayPlot 显示形状:
data = Map[If[Max[Abs[#]] ≤ 2, 1, 0]&, Flatten[iterates, {{2}, {3}, {1}}], {2}];ArrayPlot[data]对数映射的分岔图 (1)
k = 1000; r = Range[3., 4., 1 / (k - 1)];
rhs[x_ ? VectorQ] := r x(1 - x);iterates = RecurrenceTable[{x[n + 1] == rhs[x[n]], x[0] == ConstantArray[1. / π, k]}, x, {n, 10 ^ 4, 2 10 ^ 4}];//Timing缩放迭代到位于 1 和
之间的整数,并颠倒顺序,这样行对应于
:
data = Transpose[Ceiling[iterates k]];count[data_, i_] := Module[{c, j},
{j, c} = Transpose[Tally[data]];
Transpose[{j, ConstantArray[i, Length[j]]}] -> Log[N[c]]];制作一个稀疏矩阵,将统计应用 Count 到每个
的迭代上:
S = SparseArray[Table[count[data[[i]], i], {i, k}], k]用 ArrayPlot 制作分叉图表:
ArrayPlot[Reverse[S], ColorFunction -> "Rainbow"]比较常微分方程数值方法 (1)
ListPlot[Block[{h = .1}, RecurrenceTable[
{x[n + 1] == x[n] + h y[n], x[0] == 1.0,
y[n + 1] == y[n] - h Sin[x[n]], y[0] == 0.},
{x, y}, {n, 0, 300}]]]偶对的欧拉方法是稳定的,但在较大 h 下,对于初始条件是敏感的:
se[h_, {x0_, y0_}] := RecurrenceTable[
{x[n + 1] == x[n] + h y[n], x[0] == x0,
y[n + 1] == y[n] - h Sin[x[n] + h y[n]], y[0] == y0},
{x, y}, {n, 0, 500}];ListPlot[{se[.1, {2.67, 0.}], se[1., {2.67, 0.}], se[1., {2.66, 0.}]}]比较有 Manipulate 的不同向量域的方法:
Manipulate[
Block[{n, f1, f2, rhs, req, vfn},
vfn = vf /. {x -> x[n], y -> y[n]};
If[method === "Euler",
rhs = {x[n], y[n]} + h * vfn,
f1 = x[n] + h * First[vfn];
f2 = y[n] + h * (Last[vfn] /. x[n] -> f1);
rhs = {f1, f2}];
req = Thread[{x[n + 1], y[n + 1]} == rhs];
ListPlot[RecurrenceTable[{req /. h -> hh, Thread[{x[0], y[0]} == p]}, {x, y}, {n, 0, Ceiling[10 ^ ls]}], PlotRange -> {{-4, 4}, {-3, 3}}, PlotLabel -> ToString[req, TraditionalForm]]],
{{p, {2.67, 0}}, Locator}, {{ls, 4, "SubscriptBox[log, 10](SubscriptBox[n, max])"}, 1, 6}, {{hh, 1., "StepSize"}, 10 ^ -4, 2}, {{vf, {y, -Sin[x]}, "Vector Field"}, {{y, -x}, {y, -Sin[x]}, {y, x * (1 - x ^ 2)}}, ControlType -> PopupMenu}, {method, {"SymplecticEuler", "Euler"}}]标准映射 (1)
对于一列初始条件,由标准映射导致的延伸和折叠 [更多信息]:
Block[{k = 1, m = 10000}, Grid[Partition[MapIndexed[Tooltip[ListPlot[Transpose[#1], PlotStyle -> PointSize[0.01], PlotRange -> {{0, 2π}, {-2.5, 2.5}}], n == First[#2] - 1]&, RecurrenceTable[{
x[n + 1] == Mod[y[n] + x[n] + k Sin[x[n]], 2π], x[0] == ConstantArray[N[π], m], y[n + 1] == y[n] + k Sin[x[n]], y[0] == N[2 Range[m] / (m)]},
{x, y}, {n, 0, 11}]], 3]]]属性和关系 (3)
RSolve 对于这个递归方程,求出一个符号解:
RSolve[{a[n + 1] == 2a[n] + 1, a[0] == 7}, a, n]Table[a[n] /. %[[1]], {n, 0, 7}]RecurrenceTable 对于相同问题,产生一个过程解:
RecurrenceTable[{a[n + 1] == 2a[n] + 1, a[0] == 7}, a, {n, 0, 7}]使用 RecurrenceFilter 对信号滤波:
RecurrenceFilter[{{1, -(1/2)}, {1}}, {1, 0, 0, 0, 0, 0, 0, 0}]使用 RecurrenceTable 获得相同结果:
RecurrenceTable[{y[n] - (1/2)y[n - 1] == DiscreteDelta[n], y[-1] == 0}, y[n], {n, 0, 7}]用 RFixedPoints 求非线性递归方程的不动点:
RFixedPoints[x[n + 1] == (1/2)x[n](1 - x[n]), x, n]用 RStabilityConditions 分析不动点的稳定性:
RStabilityConditions[x[n + 1] == (1/2)x[n](1 - x[n]), x, n]用 RecurrenceTable 解方程:
sol = RecurrenceTable[{x[n + 1] == (1/2)x[n](1 - x[n]), x[0] == -9 / 10}, x, {n, 0, 20}, WorkingPrecision -> 10]ListPlot[sol, PlotRange -> All]巧妙范例 (1)
c = 1; k = 1 / 320; h = 0.08;sol = RecurrenceTable[{v[i, j] == c((1 - (2 k) / h ^ 2)v[i, j - 1] + (k(v[i + 1, j - 1] + v[i - 1, j - 1])) / h ^ 2),
v[i, 0] == UnitStep[2. - i h]UnitStep[i h + 2]100}, v, {i, -70, 70}, {j, 0, 300}];Table[ListLinePlot[Transpose[sol][[i]], Filling -> Axis, Ticks -> None], {i, {1, 20, 100, 300}}]ListPlot3D[Transpose[sol], Mesh -> None, PlotStyle -> {Orange, Specularity[White, 10]}]相关链接
文本
Wolfram Research (2008),RecurrenceTable,Wolfram 语言函数,https://reference.wolfram.com/language/ref/RecurrenceTable.html (更新于 2024 年).
CMS
Wolfram 语言. 2008. "RecurrenceTable." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2024. https://reference.wolfram.com/language/ref/RecurrenceTable.html.
APA
Wolfram 语言. (2008). RecurrenceTable. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/RecurrenceTable.html 年
BibTeX
@misc{reference.wolfram_2026_recurrencetable, author="Wolfram Research", title="{RecurrenceTable}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/RecurrenceTable.html}", note=[Accessed: 13-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_recurrencetable, organization={Wolfram Research}, title={RecurrenceTable}, year={2024}, url={https://reference.wolfram.com/language/ref/RecurrenceTable.html}, note=[Accessed: 13-November-2026]}