Wolfram Language

Partial Differential Equations

Study the Vibrations of a Stretched String

Study the vibrations of a stretched string using the wave equation.

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

Specify that the ends of the string remain fixed during the vibrations.

In[2]:=
Click for copyable input
bc = {u[0, t] == 0, u[\[Pi], t] == 0};

Give initial values at different points on the string.

In[3]:=
Click for copyable input
ic = {u[x, 0] == x^2 (\[Pi] - x), \!\(\*SuperscriptBox[\(u\), TagBox[ RowBox[{"(", RowBox[{"0", ",", "1"}], ")"}], Derivative], MultilineFunction->None]\)[x, 0] == 0};

Solve the initial-boundary value problem.

In[4]:=
Click for copyable input
dsol = DSolve[{weqn, bc, ic}, u, {x, t}] /. {K[1] -> m}
Out[4]=

Extract four terms from the Inactive sum.

In[5]:=
Click for copyable input
asol[x_, t_] = u[x, t] /. dsol[[1]] /. {\[Infinity] -> 4} // Activate
Out[5]=

Each term in the sum represents a standing wave.

In[6]:=
Click for copyable input
Table[Show[ Plot[Table[asol[x, t][[m]], {t, 0, 4}] // Evaluate, {x, 0, Pi}, Ticks -> False], ImageSize -> 150], {m, 4}]
Out[6]=

Visualize the vibration of the string.

In[7]:=
Click for copyable input
Animate[Plot[asol[x, t], {x, 0, \[Pi]}, PlotRange -> {-5, 5}, ImageSize -> Medium, PlotStyle -> Red], {t, 0, 2 Pi}, SaveDefinitions -> True]
Play Animation
Stop Animation

Related Examples

de es fr ja ko pt-br ru zh