阿克曼函数推导过程(m<=3)
阿克曼函数(Ackermann)是非原始递归函数的例子。它需要两个自然数作为输入值,输出一个自然数。它的输出值增长速度非常快,仅是对于(4,3)的输出已大得不能准确计算。
\[A(m, n)=\left\{\begin{array}{ll}{n+1} & {m=0} \\ {A(m-1,1)} & {m>0, n=0} \\ {A(m-1, A(m, n-1))} & {m>0, n>0}\end{array}\right.
\]
因为\(m\)很小,所以我们可以针对\(0\leq m \leq 3\)来对阿克曼函数进行推导
对于阿克曼函数的具体推导过程如下:
- 当\(m=0\)时:
\[A(0, n)=n+1
\]
- 当\(m=1\)时:
\[\begin{aligned} A(1, n) &=A(0, A(1, n-1))=A(1, n-1)+1 \\ &=A(0, A(1, n-2))=A(1, n-2)+2 \\ &=A(0, n-3)+3 \\ & \cdots \\ &=A(1,0)+n \\ &=A(0,1)+n \\ &=n+2 \end{aligned}
\]
- 当\(m=2\)时:
\[\begin{aligned} A(2, n) &=A(1, A(2, n-1))=A(2, n-1)+2 \\ &=A(1, A(2, n-2))+2 \\ &=A(2, n-2)+2 \times 2 \\ & \cdots \\ &=A(2,0)+2 \times n \\ &=A(1,1)+2 \times n \\ &=3+2 \times n \end{aligned}
\]
- 当\(m=3\)时:
\[\begin{aligned} A(3, n) &=A(2, A(3, n-1)) \\ &=A(3, n-1) \times 2+3 \\ &=A(2, A(3, n-2)) \times 2+3 \\ &=(A(3, n-2) \times 2+3) \times 2+3 \\ &=2 \times 2 \times A(3, n-2)+2 \times 3+3 \\ &=2 \times 2 \times A(3, n-2)+2 \times 3+3 \\ &=2 \times 2 \times(A(3, n-2)+2 \times 3+3) \\ &=2 \times 2 \times(A(3, n-3) \times 2+3)+2 \times 3+3 \\ &=2^{n} \times A(2,1)+3 \times\left(2^{n}-1\right) \\ &=2^{n} \times 5+2^{n} \times 3-3 \\ &=2^{n+3}-3 \end{aligned}
\]