Oscillations of a String

The following two examples use NDSolve to track the oscillations of a string, first with sliding ends, then with fixed ends. The partial differential equation describing the dynamics of a string is of course

(((∂^2) u)/(∂t ∂t))=a (((∂^2) u)/(∂x ∂x))

Oscillations with sliding ends

Needs["Graphics`FilledPlot`"]

The boundary value problem below describes a string initially set into a triangular shape and released with zero initial speed.

The ends of the string are allowed to slide in vertical direction while remaining at the same height.

\(u = y[x, t]; 

    v2 = NDSolve[{∂\_\(t, t\)u == ∂\_\(x, x\)u, 
          y[x, 0] == 0.1\ \((1 - Abs[x]\/π)\), 
          y[\(-π\), t] == y[π, t], 
          \((∂\_t u /. t -> 0)\) == 0}, 
        y, {x, \(-π\), π}, {t, 0, 13}]\)

The resulting interpolation function, again, can be plotted over the time-space domain:

\(\(Plot3D[Evaluate[y[x, t] /. First[v2]], 

      	{x, \(-π\), π}, {t, 0, 13}, PlotPoints -> 30]; \)\)

The animation below shows how the initial traingular shape (a relatively complicated shape from the vibration theory standpoint), gives rise to various sinusoidal harmonics at various periods of time.

\(For[t = 0, t <= 4  π, t += 0.25, 
	
      FilledPlot[{0., Evaluate[y[x, t] /. First[v2]], 0.1}, 

        		{x, \(-π\), π}, \ PlotRange -> All, 
        Fills -> {{{1, 2}, RGBColor[0, 1, 0]}, {{2, 3}, 
              RGBColor[1, 1, 1]}}]]; t =. ; \)

Oscillations with fixed ends

\(u = y[x, t]; 

    v3 = NDSolve[{∂\_\(t, t\)u == ∂\_\(x, x\)u, 
          y[x, 0] == 0.1*\((1 - Abs[x]\/π)\), 
		y[\(-Pi\), t] == 0, 
          y[Pi, t] == 0, 
			
          \((∂\_t\ u /. t -> 0)\) == 0}, 
	
        y, {x, \(-π\), π}, {t, 0, 17}]\)

\(\(Plot3D[Evaluate[y[x, t] /. First[v3]], 

      	{x, \(-π\), π}, {t, 0, 13}, PlotPoints -> 30]; \)\)

\(For[t = 0, t <= 4  π, t += 0.25, 
	
      FilledPlot[{\(-0.1\), Evaluate[y[x, t] /. First[v3]], 0.1}, 

        		{x, \(-π\), π}, \ PlotRange -> All, 
        Fills -> {{{1, 2}, RGBColor[0, 1, 0]}, {{2, 3}, 
              RGBColor[1, 1, 1]}}]]; t =. ; \)