Wolfram 语言

偏微分方程

求解波动方程的初值问题

指定单位传播速度的波动方程.

In[1]:=
Click for copyable input
weqn = D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}];

规定方程的初始条件.

In[2]:=
Click for copyable input
ic = {u[x, 0] == E^(-x^2), Derivative[0, 1][u][x, 0] == 1};

求解初值问题.

In[3]:=
Click for copyable input
DSolveValue[{weqn, ic}, u[x, t], {x, t}]
Out[3]=

波形沿一对特征方向传播.

In[4]:=
Click for copyable input
DSolveValue[{weqn, ic}, u[x, t], {x, t}]; Plot3D[%, {x, -7, 7}, {t, 0, 4}, Mesh -> None]
Out[4]=

用分段数据求解初值问题.

In[5]:=
Click for copyable input
ic = {u[x, 0] == UnitBox[x] + UnitTriangle[x/3], Derivative[0, 1][u][x, 0] == 0};
In[6]:=
Click for copyable input
DSolveValue[ {weqn, ic}, u[x, t], {x, t}]
Out[6]=

初始数据中的不连续处沿特征方向传播.

In[7]:=
Click for copyable input
DSolveValue[ {weqn, ic}, u[x, t], {x, t}]; Plot3D[%, {x, -7, 7}, {t, 0, 4}, PlotRange -> All, Mesh -> None, ExclusionsStyle -> Red]
Out[7]=

用指数函数的和作为初始数据求解初值问题.

In[8]:=
Click for copyable input
ic = {u[x, 0] == E^(-(x - 6)^2) + E^(-(x + 6)^2), Derivative[0, 1][u][x, 0] == 1/2};
In[9]:=
Click for copyable input
sol = DSolveValue[ {weqn, ic}, u[x, t], {x, t}]
Out[9]=

将求出的解可视化.

In[10]:=
Click for copyable input
Plot3D[sol, {x, -30, 30}, {t, 0, 20}, PlotRange -> All, Mesh -> None, PlotPoints -> 30]
Out[10]=

相关范例

de en es fr ja ko pt-br ru