User the Fourier technique to solve the wave problem
$$
\begin{array}{ll}
u_{tt} = u_{xx} & u(0,t)=u(1,t)=0 \\
u(x,0) = 0 & u_t(x,0) = x^2-x.
\end{array}
$$
A good explanation with a Mathematica illustration can earn an awesome badge.
Fourier series for a specific wave equation
To start we use seperation of variables to get two ODEs. Assuming $u(x,t)=X(x)T(t)$ and using $-\lambda^2$ as our constant we get:
$$X(x)=A (\cos (\lambda x))+B (\sin (\lambda x))$$ $$T(t)=C (\cos (\lambda t))+D (\sin (\lambda t))$$First lets apply the initial position since it will simplify $T(t)$
$$u(x,0)=T(0) X(x)=0$$
ignoring the trivial solution,
$$T(0)=C \cos(\lambda\cdot0)+D \sin (\lambda\cdot0)$$
giving $C=0$ and therefore $$T(t)=D \sin (\lambda t)$$
Now lets apply our endpoint boundaries
Left boundary:
$$u(0,t)=X(0)T(t)=0$$$$X(0)=A \cos(\lambda\cdot0)+B \sin(\lambda\cdot0)$$giving $C=0$ and therefore
$$T(t)=D \sin(\lambda x)$$
Right boundary:
$$u(1,t)=X(1) T(t)=0$$so$$X(0)=B \sin(\lambda)$$This can be true only if $\lambda=n \pi$. These are our eigenvalues.
With the appropriate choices of coefficients we have
$$u(x,t)=\sum _{n=1}^{\infty } B_n \sin (n\pi t)\sin (n\pi x)$$
where the $B_n$s are determined by our initial position and velocity. To find the coefficients we first have to take the derivative of $u(x,t)$ in respect to $t$.
$$u_t(x,t)=\sum _{n=1}^{\infty } n\pi B_n \cos (n\pi t) \sin(n\pi x)$$at $t=0$
$$u_t(x,t)=\sum _{n=1}^{\infty } n\pi B_n \sin(n\pi x)=x^2-x$$
While this is close to a Fourier series it isn't quite right. To get it into the correct format lets use a simple substitution, $C_n=n\pi B_n$. Now we have
$$u_t(x,t)=\sum _{n=1}^{\infty } C_n \sin(n\pi x)=x^2-x$$
Applying Fourier's trick
$$C_n=2 \int_0^1 (x^2-x) \sin (n\pi x) \, dx$$
Notice the $2$ out front, since we are going from 0 to 1 we are doing a half interval in comparison to an integral from $-L$ to $L$ multiplying by 2 accounts for this.
Using Mathematica we receive
$$C_n=\frac {4(-1+(-1)^n}{n^3\pi^3}$$
Notice that if $n$ is even we have 0, so if we let $n$ be odd this simplifies to
$$C_n=-\frac{8}{n^3\pi^3}$$ giving
$$B_n=-\frac{8}{n^4\pi^4}$$ and
$$u(x,t)=-\sum _{n=1}^{\infty }\frac{8}{n^4\pi^4} \sin(n\pi x)$$
To see if this was right I plotted the first $5$ terms, letting $t$ go from $0$ to $2$. It seems correct to me. The blue line is $u(x,t)$ and the other line is the initial velocity.
The code I used:
Manipulate[
Plot[{
Sum[-(8/(n^4 \[Pi]^4)) Sin[n \[Pi] t] Sin[n \[Pi] x], {n, 1, 9, 2}]
, x^2 - x},
{x, 0, 1}, PlotRange -> {-.3, .3}],
{t, 0, 2}]
That is most definitely awesome! I checked it by plotting the derivative of your approximation evaluated at $t=0$ together with the initial condition on $u_t$.
u[x_, t_] = Sum[
-(8/(n^4 Pi^4)) Sin[n Pi t] Sin[n Pi x],
{n, 1, 9, 2}];
ut[x_, t_] = D[u[x, t], t];
Plot[{ut[x, 0], x^2 - x}, {x, 0, 1},
PlotStyle -> {
Directive[Thickness[0.02], Gray],
Directive[Darker[Red]]},
AspectRatio -> Automatic]
Oh cool! When I first tried something I bungled it and it looked like the approximation was horribly off. I'm glad that check works out.