# [SOLVED]wave equation soln check and plot question

#### dwsmith

##### Well-known member
\begin{alignat*}{3}
u_{tt} & = & c^2u_{xx}\\
u(0,t) & = & 0\\
u_x(L,t) & = & 0\\
u(x,0) & = & \frac{x}{L}\\
u_t(x,0) & = & 0

\end{alignat*}

Let's start with $u_t(x,0) = 0$. Then
$$u_t(x,0) = \sum_{n = 1}^{\infty}B_n\frac{\pi c}{L}\left(n + \frac{1}{2}\right)\sin\left[\frac{\pi x}{L}\left(n + \frac{1}{2}\right)\right] = 0.$$
That is, $B_n = 0$. Using the first initial condition, we have
$$u(x,0) = \sum_{n = 1}^{\infty}A_n\sin\left[\frac{\pi x}{L}\left(n + \frac{1}{2}\right)\right] = \frac{x}{L}.$$
Now we can solve for the Fourier coefficient $A_n$.
\begin{alignat*}{3}
A_n & = & \frac{2}{L^2}\int_0^{\pi}x\sin\left[\frac{\pi x}{L}\left(n + \frac{1}{2}\right)\right]dx\\
& = & \left.\frac{-4(2n + 1)x\pi\cos\left[\left(n + \frac{1}{2}\right)\frac{\pi x}{L}\right] + 8L\sin\left[\left(n + \frac{1}{2}\right)\frac{\pi x}{L}\right]}{L\pi^2(2n + 1)^2}\right|_0^{\pi}\\
& = & \frac{8\cos n\pi + 4(2n + 1)\pi\sin n\pi}{\pi^2(2n + 1)^2}\\
& = & \frac{8(-1)^n}{\pi^2(2n + 1)^2}
\end{alignat*}
So the solution is
$$u(x,t) = \frac{8}{\pi^2}\sum_{n = 1}^{\infty}\frac{(-1)^n}{(2n + 1)^2}\sin\left[\frac{\pi x}{L}\left(n + \frac{1}{2}\right)\right]\cos\left[\frac{\pi ct}{L}\left(n + \frac{1}{2}\right)\right].$$
When $L = \pi$ and $c = 1$, we have $u(x,t) = \frac{8}{\pi^2}\sum\limits_{n = 1}^{\infty}\frac{(-1)^n}{(2n + 1)^2}\sin\left[x\left(n + \frac{1}{2}\right)\right]\cos\left[t\left(n + \frac{1}{2}\right)\right]$.

Plot the bar displacement distribution at 10 equally-spaced times during one period of oscillation. What is this asking me to do?

#### Ackbach

##### Indicium Physicus
Staff member
\begin{alignat*}{3}
u_{tt} & = & c^2u_{xx}\\
u(0,t) & = & 0\\
u_x(L,t) & = & 0\\
u(x,0) & = & \frac{x}{L}\\
u_t(x,0) & = & 0

\end{alignat*}

Let's start with $u_t(x,0) = 0$. Then
$$u_t(x,0) = \sum_{n = 1}^{\infty}B_n\frac{\pi c}{L}\left(n + \frac{1}{2}\right)\sin\left[\frac{\pi x}{L}\left(n + \frac{1}{2}\right)\right] = 0.$$
That is, $B_n = 0$. Using the first initial condition, we have
$$u(x,0) = \sum_{n = 1}^{\infty}A_n\sin\left[\frac{\pi x}{L}\left(n + \frac{1}{2}\right)\right] = \frac{x}{L}.$$
Now we can solve for the Fourier coefficient $A_n$.
\begin{alignat*}{3}
A_n & = & \frac{2}{L^2}\int_0^{\pi}x\sin\left[\frac{\pi x}{L}\left(n + \frac{1}{2}\right)\right]dx\\
& = & \left.\frac{-4(2n + 1)x\pi\cos\left[\left(n + \frac{1}{2}\right)\frac{\pi x}{L}\right] + 8L\sin\left[\left(n + \frac{1}{2}\right)\frac{\pi x}{L}\right]}{L\pi^2(2n + 1)^2}\right|_0^{\pi}\\
& = & \frac{8\cos n\pi + 4(2n + 1)\pi\sin n\pi}{\pi^2(2n + 1)^2}\\
& = & \frac{8(-1)^n}{\pi^2(2n + 1)^2}
\end{alignat*}
So the solution is
$$u(x,t) = \frac{8}{\pi^2}\sum_{n = 1}^{\infty}\frac{(-1)^n}{(2n + 1)^2}\sin\left[\frac{\pi x}{L}\left(n + \frac{1}{2}\right)\right]\cos\left[\frac{\pi ct}{L}\left(n + \frac{1}{2}\right)\right].$$
When $L = \pi$ and $c = 1$, we have $u(x,t) = \frac{8}{\pi^2}\sum\limits_{n = 1}^{\infty}\frac{(-1)^n}{(2n + 1)^2}\sin\left[x\left(n + \frac{1}{2}\right)\right]\cos\left[t\left(n + \frac{1}{2}\right)\right]$.

Plot the bar displacement distribution at 10 equally-spaced times during one period of oscillation. What is this asking me to do?
What is "the bar"? Are you solving the wave equation on a bar of some sort?

#### dwsmith

##### Well-known member
What is "the bar"? Are you solving the wave equation on a bar of some sort?
Yes

#### topsquark

##### Well-known member
MHB Math Helper
Find how long one period of the motion is (call it T) then at each T/10 find out what u(x, t) is. ie. You'll have a plot of x vs u(x, NT/10) (where N is a number between 1 and 10) for each N.

That's my 2 cents.

-Dan

PS The summation looks a lot nicer if you use $$sin(2X) = 2~sin(X)~cos(X)$$

#### dwsmith

##### Well-known member
Find how long one period of the motion is (call it T) then at each T/10 find out what u(x, t) is. ie. You'll have a plot of x vs u(x, NT/10) (where N is a number between 1 and 10) for each N.

That's my 2 cents.

-Dan

PS The summation looks a lot nicer if you use $$sin(2X) = 2~sin(X)~cos(X)$$
Do you know how I could construct that with Mathematica? Sine and cosine are different though. Sine has a x and cosine a t, so how can they be combined?

#### topsquark

##### Well-known member
MHB Math Helper
Sine and cosine are different though. Sine has a x and cosine a t, so how can they be combined?
Ummm....Well....Okay, I goofed.

Let's try this though.
$$sin(A)~cos(B) = \frac{1}{2} \cdot ( sin(A + B) + sin(A - B) )$$

So the trig function part of the summation gives
$$\sin \left [ (x + t) \left ( n + \frac{1}{2} \right ) \right ] + \sin \left [ (x - t) \left ( n + \frac{1}{2} \right ) \right ]$$

I like this form better because it reminds me of the good old-fashioned wave packet stuff they made me learn in Quantum.

Mathematica says the series converges. I haven't tried to plot anything, but the series looks like it ought to behave well. Maybe you can just use the first few n's to approximate the shape?

-Dan

#### dwsmith

##### Well-known member
Ummm....Well....Okay, I goofed.

Let's try this though.
$$sin(A)~cos(B) = \frac{1}{2} \cdot ( sin(A + B) + sin(A - B) )$$

So the trig function part of the summation gives
$$\sin \left [ (x + t) \left ( n + \frac{1}{2} \right ) \right ] + \sin \left [ (x - t) \left ( n + \frac{1}{2} \right ) \right ]$$

Mathematica says the series converges. I haven't tried to plot anything, but the series looks like it ought to behave well. Maybe you can just use the first few n's to approximate the shape?

-Dan
That is d'Almbert's solution. I am aware of it. My true problem is the plotting in Mathematica software.

#### dwsmith

##### Well-known member
How will the period be determined? Wont it be different at each time step?

Code:
Nmax = 50;
L = Pi;
c = 1;
\[Lambda] = Table[Pi/L*(n + 1/2), {n, 1, Nmax}];
MyTime = Table[t, {t, 1, 10, 1}];
f[x_] = x;

A = Table[
2/L*Integrate[f[x]*Sin[\[Lambda][[n]]*x], {x, 0, L}], {n, 1, Nmax}];
u[x_, t_] =
Sum[Sin[x*\[Lambda][[n]]]*Cos[t*\[Lambda][[n]]], {n, 1, Nmax}];
Plot[u[x, MyTime], {x, 0, .135}, PlotStyle -> {Red}, PlotRange -> All,
AspectRatio -> 3/4]

Last edited:

#### topsquark

##### Well-known member
MHB Math Helper
That is d'Almbert's solution. I am aware of it. My true problem is the plotting in Mathematica software.
That is a problem. As I'm sure you've realized there is no wavelength for the wave packet as n goes to infinity.

Perplexing.

-Dan

#### dwsmith

##### Well-known member
That is a problem. As I'm sure you've realized there is no wavelength for the wave packet as n goes to infinity.

Perplexing.

-Dan
I have something but I am not sure if it is right. See my first previous post.

#### topsquark

##### Well-known member
MHB Math Helper
I have something but I am not sure if it is right. See my first previous post.
Sorry. I'm not sure what you are working on.

-Dan

#### dwsmith

##### Well-known member
Sorry. I'm not sure what you are working on.

-Dan
Plotting the function at 10 equal time steps in one period.