Mathematica 中非线性 ODE 的初始条件

发布于 2024-09-06 04:44:32 字数 702 浏览 5 评论 0原文

我正在尝试使用 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 技术交流群。

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

发布评论

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

评论(2

清醇 2024-09-13 04:44:32

嗯,正如错误消息所述 - NDSolve 只接受严格小于 ODE 中出现的最大阶数的导数的初始条件。
我感觉这更像是一道数学问题。从数学上讲,{x''[0]=-x0, x[0]==x0} 并没有定义唯一的解决方案 - 您必须按照 的方式做一些事情>{x0.x''[0]==-1, x[0]==x0, x'[0]-x0 x0.x'[0]==v0} 来解决这个问题(NDSolve 仍然会失败并出现相同的错误)。您确实意识到您只会在单位球体上得到一个大圆,对吧?

顺便说一下,以下是我对您的示例进行编码的方式:

x[t_] = Table[Subscript[x, j][t], {j, 3}];
s1 = NDSolve[Flatten[Thread /@ #] &@{
       x''[t] - (x''[t].x[t]) x[t] == {0, 0, 0},
       x[0] == {1, 0, 0}, 
       x'[0] == {0, 0, 1}
     }, x[t], {t, -1, 1}]

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:

x[t_] = Table[Subscript[x, j][t], {j, 3}];
s1 = NDSolve[Flatten[Thread /@ #] &@{
       x''[t] - (x''[t].x[t]) x[t] == {0, 0, 0},
       x[0] == {1, 0, 0}, 
       x'[0] == {0, 0, 1}
     }, x[t], {t, -1, 1}]
夜夜流光相皎洁 2024-09-13 04:44:32

我通过数学重新排列解决了这个问题,而不是解决我原来的问题:

让 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.

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