Wolfram Language

Partial Differential Equations

Solve a Dirichlet Problem for the Helmholtz Equation

Specify a Helmholtz equation in 2D.

In[1]:=
Click for copyable input
heqn = {Laplacian[u[x, y], {x, y}] + 5 u[x, y] == 0};

Prescribe Dirichlet conditions for the equation in a rectangle.

In[2]:=
Click for copyable input
bc = {u[x, 0] == UnitTriangle[x - 2]/2, u[x, 2] == 0, u[0, y] == 0, u[4, y] == 0};

Solve the Dirichlet problem using DSolveValue.

In[3]:=
Click for copyable input
(sol = DSolveValue[{heqn, bc}, u[x, y], {x, y}]) // TraditionalForm
Out[3]//TraditionalForm=

Extract the first 30 terms from the Inactive sum.

In[4]:=
Click for copyable input
fsol = sol /. \[Infinity] -> 30 // Activate;

Visualize the approximate solution.

In[5]:=
Click for copyable input
Plot3D[fsol // Evaluate, {x, 0, 4}, {y, 0, 2}, PlotRange -> All, PlotTheme -> "Scientific"]
Out[5]=

Related Examples

de es fr ja ko pt-br ru zh