Mathematica 方程返回 true 而不是求解 ODE?
Mathematica equations returning true instead of solving ODE?
我想使用 Mathematica 的 DSolve 函数求解一个包含两个 ODE 的方程组。这是我写下的内容:
DSolve[{x'[t] == 0.02*x - .00004*x*y, y'[t] == .0004*x*y - .04*y,
x[0] == 500, y[0] == 200}, {x[t], y[t]}, t]
但出于某种原因,它一直告诉我方程式 return 是正确的,我不应该在我的语法中包含它,它不会解决它。不确定为什么会发生这种情况或如何解决它。
问题:
DSolve::dvnoarg: The function x appears with no arguments. >>
您应该在等式中放置 x[t]
而不是 x
。
NIntegrate::nlim: K[1] = x[t] is not a valid limit of integration. >>
你应该使用数值解,因为解析有问题。
解决方案:
s = NDSolve[
{
x'[t] == 0.02*x[t] - .00004*x[t]*y[t],
y'[t] == .0004*x[t]*y[t] - .04*y[t],
x[0] == 500,
y[0] == 200
}, {x, y}, {t, 0, 100}]
Plot[{Evaluate[x[t] /. s], Evaluate[y[t] /. s]}, {t, 0, 100}]
结果:
我想使用 Mathematica 的 DSolve 函数求解一个包含两个 ODE 的方程组。这是我写下的内容:
DSolve[{x'[t] == 0.02*x - .00004*x*y, y'[t] == .0004*x*y - .04*y,
x[0] == 500, y[0] == 200}, {x[t], y[t]}, t]
但出于某种原因,它一直告诉我方程式 return 是正确的,我不应该在我的语法中包含它,它不会解决它。不确定为什么会发生这种情况或如何解决它。
问题:
DSolve::dvnoarg: The function x appears with no arguments. >>
您应该在等式中放置 x[t]
而不是 x
。
NIntegrate::nlim: K[1] = x[t] is not a valid limit of integration. >>
你应该使用数值解,因为解析有问题。
解决方案:
s = NDSolve[
{
x'[t] == 0.02*x[t] - .00004*x[t]*y[t],
y'[t] == .0004*x[t]*y[t] - .04*y[t],
x[0] == 500,
y[0] == 200
}, {x, y}, {t, 0, 100}]
Plot[{Evaluate[x[t] /. s], Evaluate[y[t] /. s]}, {t, 0, 100}]