如何求解mathematica中递推关系的解析解

发布于 2024-10-16 09:38:30 字数 321 浏览 1 评论 0原文

我再次遇到如下情况:

RSolve[{f[m, n] == f[m, n - 1] + f[m - 1, n], 
        f[0, n] == 1, f[m, 0] == 1}, 
        f[m, n], {n}]

我尝试使用 RSolve,但出现错误:

RSolve::deqx: Supplied equations are not difference equations 
              of the given functions.

感谢您的帮助!

I have a recurrence such as following:

RSolve[{f[m, n] == f[m, n - 1] + f[m - 1, n], 
        f[0, n] == 1, f[m, 0] == 1}, 
        f[m, n], {n}]

I tried to use RSolve, but I got an error:

RSolve::deqx: Supplied equations are not difference equations 
              of the given functions.

Appreciate your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清风不识月 2024-10-23 09:38:30

差分方程和初始条件为
差分方程

Mathematica(7 和 8)不喜欢求解它......无论有没有初始条件。 RSolve 表达式未计算,

In[1]:= RSolve[{f[m,n]==f[m,n-1]+f[m-1,n],f[0,n]==f[m,0]==1},f[m,n],{m,n}]
        RSolve[{f[m,n]==f[m,n-1]+f[m-1,n]},f[m,n],{m,n}]
Out[1]= RSolve[{f[m,n]==f[-1+m,n]+f[m,-1+n],f[0,n]==f[m,0]==1},f[m,n],{m,n}]
Out[2]= RSolve[{f[m,n]==f[-1+m,n]+f[m,-1+n]},f[m,n],{m,n}]

知道 Mathematica 使用 生成函数方法(可能除其他外)来解决此类递归问题,但我不知道为什么它失败在如此简单的情况下。

那么让我们手动完成吧。

设 g(x,n) 为 f(m,n) 的生成函数
在此处输入图像描述

现在检查 f(m+1,n) x^m 的总和
在此处输入图像描述

现在求解简单的代数差分方程:
在此处输入图像描述

也可以使用 RSolve

In[3]:= RSolve[g[x,n]-x g[x,n]==g[x,n-1]&&g[x,0]==1/(1-x),g[x,n],n];
        Simplify[%,Element[n,Integers]]
Out[4]= {{g[x,n]->(1-x)^(-1-n)}}

现在提取 x^m 的系数:

In[5]:= SeriesCoefficient[(1 - x)^(-1 - n), {x, 0, m}]
Out[5]= Piecewise[{{(-1)^m*Binomial[-1 - n, m], m >= 0}}, 0]

使用二项式简化

In[6]:= FullSimplify[(-1)^m*Binomial[-n - 1, m] == Binomial[m + n, m], Element[{n,m}, Integers]&&m>0&&n>0 ]
Out[6]= True

所以我们最终得到
结果!

这可以使用符号和数字方式进行检查

In[7]:= ff[m_,n_]:=ff[m,n]=ff[m-1,n]+ff[m,n-1]
        ff[0,_]:=1;ff[_,0]:=1
In[9]:= And@@Flatten[Table[ff[m,n]==Binomial[n+m,m],{n,0,20},{m,0,20}]]
Out[9]= True

In[10]:= {f[m,n]==f[m,n-1]+f[m-1,n],f[0,n]==f[m,0]==1}/.f->(Binomial[#1+#2,#1]&)//FullSimplify
Out[10]= {True,True}

The difference equation and initial conditions are
difference equation

Mathematica (7 and 8) does not like solving it... both with and without initial conditions. The RSolve expressions are left unevaluated

In[1]:= RSolve[{f[m,n]==f[m,n-1]+f[m-1,n],f[0,n]==f[m,0]==1},f[m,n],{m,n}]
        RSolve[{f[m,n]==f[m,n-1]+f[m-1,n]},f[m,n],{m,n}]
Out[1]= RSolve[{f[m,n]==f[-1+m,n]+f[m,-1+n],f[0,n]==f[m,0]==1},f[m,n],{m,n}]
Out[2]= RSolve[{f[m,n]==f[-1+m,n]+f[m,-1+n]},f[m,n],{m,n}]

I know that Mathematica uses generating functional methods (probably among other things) to solve such recurrences, but I don't know why it fails in such a simple case.

So let's do it by hand.

Let g(x,n) be the generating function for f(m,n)
enter image description here

Now examine the sum of f(m+1,n) x^m
enter image description here

Now solve the simple algebraic-difference equation:
enter image description here

Which can also be done with RSolve

In[3]:= RSolve[g[x,n]-x g[x,n]==g[x,n-1]&&g[x,0]==1/(1-x),g[x,n],n];
        Simplify[%,Element[n,Integers]]
Out[4]= {{g[x,n]->(1-x)^(-1-n)}}

Now extract the coefficient of x^m:

In[5]:= SeriesCoefficient[(1 - x)^(-1 - n), {x, 0, m}]
Out[5]= Piecewise[{{(-1)^m*Binomial[-1 - n, m], m >= 0}}, 0]

The binomial is simplified using

In[6]:= FullSimplify[(-1)^m*Binomial[-n - 1, m] == Binomial[m + n, m], Element[{n,m}, Integers]&&m>0&&n>0 ]
Out[6]= True

So we finally get
Results!

This can be checked using symbolic and numeric means

In[7]:= ff[m_,n_]:=ff[m,n]=ff[m-1,n]+ff[m,n-1]
        ff[0,_]:=1;ff[_,0]:=1
In[9]:= And@@Flatten[Table[ff[m,n]==Binomial[n+m,m],{n,0,20},{m,0,20}]]
Out[9]= True

In[10]:= {f[m,n]==f[m,n-1]+f[m-1,n],f[0,n]==f[m,0]==1}/.f->(Binomial[#1+#2,#1]&)//FullSimplify
Out[10]= {True,True}
雅心素梦 2024-10-23 09:38:30

不是答案,但似乎正确的形式应该是(注意最后的 {m, n}):

RSolve[{f[m, n] == f[m, n - 1] + f[m - 1, n], f[0, n] == 1, f[m, 0] == 1}, f[m, n], {m, n}]

Mathematica 对此不进行评估。我认为这根本无法解决这个问题。

Not the answer but it seems that the right form should be (note {m, n} at the end):

RSolve[{f[m, n] == f[m, n - 1] + f[m - 1, n], f[0, n] == 1, f[m, 0] == 1}, f[m, n], {m, n}]

Mathematica leaves this unevaluated. I think it just cannot solve this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文