Mathematica 求解微分方程 [英] Mathematica solving differential equations

查看:50
本文介绍了Mathematica 求解微分方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用数字找到

u_t - u_xx - u_yy = f 在正方形 y ∈ [0,1], x ∈ [0,1]

u_t - u_xx - u_yy = f on the square y ∈ [0,1], x ∈ [0,1]

如果在单位圆中 f=1,否则 f=0.所有四个边上的边界条件均为 u=0.

where f=1 if in the unit circle and f=0 otherwise. The boundary conditions are u=0 on all four edges.

我一直在尝试使用 ND-solve,但我不断收到错误消息.我是 Mathematica 的新手,所以我不知道如何在 ND-Solve 之前定义 f.

I have been trying to use ND-solve for ages but I keep getting error messages. I'm new to Mathematica so I don't know how to define f before ND-Solve.

提前致谢.

推荐答案

Mathematica 帮助文件对于此类内容非常完整.我要参考在线版本,但请注意,在帮助在 Mathematica 浏览器中,您可以交互式地修改和评估帮助示例.这是我了解 Mathematica 的唯一途径.

The Mathematica help files are incredibly complete for stuff like this. I'm going to reference the online version, but note that, in the help browser in Mathematica, you can interactively modify and evaluate the help examples. This was the only way I learned much about Mathematica.

在开始尝试更多事情之前的一点:在打算进行比较时定义一个函数非常容易,例如 uf.解决潜在的遗留问题的可靠但有点懒惰的方法是退出当前内核,然后再次评估某些内容.退出内核会丢失您可能在那时意外定义的所有符号.(启动新内核也是 Mathematica 在您第一次执行任何操作时会稍微搅动的原因,即使它是简单的加法.)

One point before you start trying more things: It's very easy to define a function, such as u or f when intending to make a comparison statement. A surefire, but somewhat lazy, way of fixing potential lingering problems from this is to quit the current kernel and then evaluate something again. Quitting the kernel loses all symbols you may have accidentally defined up to that point. (Starting up a new kernel is also why Mathematica churns a little bit the first time you do any operation, even if it's simple addition.)

继续手头的问题......在我上面链接的参考文献中,给出了一个示例,该示例解决了与您的示例非常相似的一维热方程.让我们从它开始并修改它:

Continuing on with the question at hand... In the reference I linked above, a sample is given which solves the one-dimensional heat equation which is very similar to your example. Let's start with that and modify it:

NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == Q0, 
  u[t, 0] == Sin[t], u[t, 5] == 0},
  u, {t, 0, 10}, {x, 0, 5}]

他们的方程是∂ut = ∂uxx,初始能量的边界条件为Q0em> 在时间 0 ∀x,x = 0 处的能量为 sin(t)x = 5 处的能量为 0∀t.你可以在上面看到那些地图是如何有希望的.现在,让我们尝试对您的条款进行相同的操作:

Their equations are ∂ut = ∂uxx with boundary conditions of the initial energy being Q0 at time 0 ∀x, the energy at x = 0 being sin(t) and the energy at x = 5 being 0 ∀t. You can see above how those map hopefully. Now, let's try to the same for your terms:

NDSolve[{D[u[t, x, y], t] - D[u[t, x, y], x, x] - D[u[t, x, y], y, y] == f[x, y],
  f[x,y] == If[x^2 + y^2 < 1, 1, 0],
  u[t, 0, y] == 0, u[t, 1, y] == 0, 
  u[t, x, 0] == 0, u[t, y, 1] == 0 }
  u, {x, 0, 1}, {y, 0, 1}]

我认为这是对的.但是,这里至少还存在一个问题.t 仍然是一个自由变量.您没有提供任何方程来限制它,因此系统未指定.

I think that's about right. However, there's at least one problem here still, though. t is still a free variable. You didn't provide any equations to restrain it, so the system is underspecified.

这篇关于Mathematica 求解微分方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆