我在Mathematica中用NDSolve解决常微分方程问题时发现了一个令人困惑的问题,代码如下:我尝试了'Clear[Derivative]'
并重启内核,但这些方法都不起作用。代码:
Clear[Derivative];
ClearSystemCache;
r = 0.3; a = 3; delta = 0.45; M0 = 0.975; T = 20;
u[t] = 0.5*l[t]*delta*M[t];
eql1 = M'[t] == r*M[t] Log[1/M[t]] - u[t]*delta*M[t];
eql2 = l'[t] == -2 *a *M[t] - l[t]* r *Log[1/M[t]] + l[t]*r -
l[t]*u[t]*delta;
condition = {M[0] == M0, l[T] == 0};
sol = NDSolve[Flatten@{{eql1, eql2}, condition}, {M, l}, {t, 0, 20}]
The result is as follows:
Power::infy: Infinite expression 1/0. encountered.
Infinity::indet: Indeterminate expression 0. \[Infinity] encountered.
Power::infy: Infinite expression 1/0. encountered.
Infinity::indet: Indeterminate expression 0. \[Infinity] encountered.
Power::infy: Infinite expression 1/0. encountered.
General::stop: Further output of Power::infy will be suppressed during this calculation.
Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered.
General::stop: Further output of Infinity::indet will be suppressed during this calculation.
NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.
我不明白为什么会有"non-numerical value for a derivative at t == 0
",t==0不应该有非数值,t<=20的时候整个Mt应该是>0的,我花了很多时间在这个问题上,还是找不到答案,请帮帮我。诚挚的问候!
发布于 2019-05-18 11:53:52
这些代码不能工作的原因是,mathematica不能解决具有奇异点和有界条件的常微分方程。我使用python编写Ronge-Kutta方法来解决这个问题,并且它是有效的。人生苦短,我用的是python :>
https://stackoverflow.com/questions/56023820
复制相似问题