Mathematica 中非线性 ODE 的初始条件
我正在尝试使用 Mathematica 的 NDSolve[] 使用耦合 ODE 计算沿球体的测地线:
x" - (x" . x) x = 0
问题是我只能输入 x(0) 和 x'(0) 的初始条件,并且求解器对解决方案,其中 x" = 0。问题是我在球体上的测地线具有 x"(0) = -x(0) 的初始条件,我不知道如何告诉 mathematica。如果我将其添加为条件,它会表示我将 True 添加到条件列表中。
这是我的代码:
s1 = NDSolve[{x1''[t] - (x1[t] * x1''[t] + x2[t] * x2''[t] + x3[t]*x3''[t]) * x1[t] == 0, x2''[t] - (x1[t] * x1''[t] + x2[t] * x2''[t] + x3[t]*x3''[t]) * x2[t] == 0, x3''[t] - (x1[t] * x1''[t] + x2[t] * x2''[t] + x3[t]*x3''[t]) * x3[t] == 0, x1[0] == 1, x2[0] == 0, x3[0] == 0, x1'[0] == 0, x2'[0] == 0, x3'[0] == 1} , { x1, x2, x3}, {t, -1, 1}][[1]]
我想修改它,使初始加速度不为零,而是 -x(0)
。
谢谢
I'm trying to use Mathematica's NDSolve[] to compute a geodesic along a sphere using the coupled ODE:
x" - (x" . x) x = 0
The problem is that I can only enter initial conditions for x(0) and x'(0) and the solver is happy with the solution where x" = 0. The problem is that my geodesic on the sphere has the initial condition that x"(0) = -x(0), which I have no idea how to tell mathematica. If I add this as a condition, it says I'm adding True to the list of conditions.
Here is my code:
s1 = NDSolve[{x1''[t] - (x1[t] * x1''[t] + x2[t] * x2''[t] + x3[t]*x3''[t]) * x1[t] == 0, x2''[t] - (x1[t] * x1''[t] + x2[t] * x2''[t] + x3[t]*x3''[t]) * x2[t] == 0, x3''[t] - (x1[t] * x1''[t] + x2[t] * x2''[t] + x3[t]*x3''[t]) * x3[t] == 0, x1[0] == 1, x2[0] == 0, x3[0] == 0, x1'[0] == 0, x2'[0] == 0, x3'[0] == 1} , { x1, x2, x3}, {t, -1, 1}][[1]]
I would like to modify this so that the initial acceleration is not zero but -x(0)
.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,正如错误消息所述 - NDSolve 只接受严格小于 ODE 中出现的最大阶数的导数的初始条件。
我感觉这更像是一道数学问题。从数学上讲,
{x''[0]=-x0, x[0]==x0}
并没有定义唯一的解决方案 - 您必须按照的方式做一些事情>{x0.x''[0]==-1, x[0]==x0, x'[0]-x0 x0.x'[0]==v0}
来解决这个问题(NDSolve 仍然会失败并出现相同的错误)。您确实意识到您只会在单位球体上得到一个大圆,对吧?顺便说一下,以下是我对您的示例进行编码的方式:
Well, as the error message says -- NDSolve only accepts initial conditions for derivatives of orders strictly less than the maximal order appearing in the ODE.
I have a feeling this is more of a mathematics question. Mathematically,
{x''[0]=-x0, x[0]==x0}
, doesn't define a unique solution - you'd have to do something along the lines of{x0.x''[0]==-1, x[0]==x0, x'[0]-x0 x0.x'[0]==v0}
for that to work out (NDSolve would still fail with the same error). You do realize you will just get a great circle on the unit sphere, right?By the way, here is how I would have coded up your example:
我通过数学重新排列解决了这个问题,而不是解决我原来的问题:
让 V(t) 是沿 x(t) 的向量场。
x 。 V = 0 意味着 d/dt (x . V) = (x' . V) + (x . V') = 0
因此方程 D/dt V = V' - (x . V') x = V' + (x' .V) x 成立
这意味着测地线方程变为: x" + (x' . x') x = 0,因此可以使用我最初拥有的初始条件来求解它。
非常感谢 Janus 经历并指出了我遇到的各种问题包括可怕的代码布局,我也通过你的重写学到了很多东西。
I fixed this problem through a mathematical rearrangement rather than addressing my original issue:
Let V(t) be a vector field along x(t).
x . V = 0 implies d/dt (x . V) = (x' . V) + (x . V') = 0
So the equation D/dt V = V' - (x . V') x = V' + (x' . V) x holds
This means the geodesic equation becomes: x" + (x' . x') x = 0 and so it can be solved using the initial conditions I originally had.
Thanks a lot Janus for going through and pointing out the various problems I was having including horrible code layout, I learnt a lot through your re-writing as well.