While solving following PDE I stumbled upon a problem in the last step:
$\ u_t-16u_{xx}=0, x\in(0,1), t \gt 0 $
$\ u(t,0)=u(t,1)=0, t\gt 0 $
$\ u(0,x)=\begin{cases} x^2, & x\lt \frac{1}{2} \\ (1-x)^2, & x\geq \frac{1}{2} \end{cases} $
Now, using separation of variables I find:
$\ u(x,t)=\sum_{i=0}^n c_n\cdot e^{-k^2 \pi^216t}\cdot\sin(n\pi x) $
Usually, if the initial datum wasn't split I would proceed with comparison of coefficients to deduce existing $ c_n $ coefficients but I see no way of applying it here. Am I making a mistake in the separation of variable process or is there a way for solving cases where the initial datum is split depending on x?
Hints and solutions are appreciated!
You need to split the computations up. You have
\begin{align} u(x,t) &= \sum_{k} c_{k} e^{-16 k^{2} \pi^{2} t} \sin (k \pi x) \\ \implies u(x,0) &= \sum_{k} c_{k} \sin (k \pi x) \\ &= \begin{cases} x^2, & x\lt \frac{1}{2} \\ (1-x)^2, & x\geq \frac{1}{2} \end{cases} \end{align}
Taking the inner product with $\sin(n \pi x)$ on both sides over $[0,1/2]$ gives
\begin{align} \sum_{k} c_{k} \int_{0}^{1/2} \sin (k \pi x) \sin (n \pi x) dx &= \begin{cases} 0, & k \ne n \\ c_{n}/4, & k = n \end{cases} \\ &= \int_{0}^{1/2} x^{2} \sin (n \pi x) dx \\ \implies c_{n} &= 4 \int_{0}^{1/2} x^{2} \sin (n \pi x) dx \end{align}
and you need to integrate by parts to get the explicit form of the coefficients $c_{n}$. Similarly,
\begin{align} \sum_{k} c_{k} \int_{1/2}^{1} \sin (k \pi x) \sin (n \pi x) dx &= \begin{cases} 0, & k \ne n \\ c_{n}/4, & k = n \end{cases} \\ &= \int_{1/2}^{1} (1 - x)^{2} \sin (n \pi x) dx \\ \implies c_{n} &= 4 \int_{1/2}^{1} (1 - x)^{2} \sin (n \pi x) dx \end{align}
Then the final solution will be
\begin{align} u(x,t) &= \sum_{k} \left( 4 \int_{0}^{1/2} x^{2} \sin (k \pi x) dx \right) e^{-16 k^{2} \pi^{2} t} \sin (k \pi x) \\ &+ \sum_{k} \left( 4 \int_{1/2}^{1} (1 - x)^{2} \sin (k \pi x) dx \right) e^{-16 k^{2} \pi^{2} t} \sin (k \pi x) \end{align}