# Wolfram Language™

## Study the Vibrations of a Stretched String

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

In:= `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:= `bc = {u[0, t] == 0, u[\[Pi], t] == 0};`

Give initial values at different points on the string.

In:= ```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:= `dsol = DSolve[{weqn, bc, ic}, u, {x, t}] /. {K -> m}`
Out= Extract four terms from the Inactive sum.

In:= `asol[x_, t_] = u[x, t] /. dsol[] /. {\[Infinity] -> 4} // Activate`
Out= Each term in the sum represents a standing wave.

In:= ```Table[Show[ Plot[Table[asol[x, t][[m]], {t, 0, 4}] // Evaluate, {x, 0, Pi}, Ticks -> False], ImageSize -> 150], {m, 4}]```
Out= Visualize the vibration of the string.

In:= ```Animate[Plot[asol[x, t], {x, 0, \[Pi]}, PlotRange -> {-5, 5}, ImageSize -> Medium, PlotStyle -> Red], {t, 0, 2 Pi}, SaveDefinitions -> True]``` 