I am solving $$u_{tt}=4u_{xx}$$ $$u(x,0)=x^2-x$$ $$u_t(x,0)=\cos x$$ $$u(0,t)=u(1,t)=0$$
I am trying to solve with the method of separable factors. So I am trying to find a equation like $u(x,t)=X(x)\cdot T(t)$. But, I am finding a problem, because if the solution is like this, then $u_t(x,0)=X(x)\cdot T'(0) = \cos x\Rightarrow X(x) = \frac{\cos x}{T'(0)}$.
But if $X(x)$ is this way, then $X(0)=\frac{\cos 0}{T'(0)}\neq 0$.
Am I solving this right or the problem is not well posed?
The separated solutions of $u_{tt}=4u_{xx}$ have the form $u(x,t)=X(x)T(t)$ where $$ \frac{T''}{T}=\lambda = \frac{X''}{X} $$
leading to
$$ T(t) = A\sin(\sqrt{\lambda}t)+B\cos(\sqrt{\lambda}t) \\ X(x) = C\sin(\sqrt{\lambda}x)+D\cos(\sqrt{\lambda}x). $$
The condition $X(0)=X(1)=0$ requires $\sqrt{\lambda}=n\pi$ for $n=1,2,3,\cdots$, and $$ X_n(t)=C_n\sin(n\pi x) \\ T_n(t)=A_n\cos(n\pi t)+B_n\sin(n\pi t). $$ The general solution (after combining constants) is $$ u(x,t)=\sum_{n=1}^{\infty}(A_n\cos(n\pi t)+B_n\sin(n\pi t))\sin(n\pi x) $$
The constants are determined by the initial conditions: $$ x^2-x = u(x,0) = \sum_{n=1}^{\infty}A_n\sin(n\pi x) \\ \cos(x) = u_t(x,0) = \sum_{n=1}^{\infty}B_n n\pi\sin(n\pi x). $$ So, $$ A_n = \frac{\int_{0}^{1}(x^2-x)\sin(n\pi x)dx}{\int_{0}^{1}\sin^2(n\pi x)dx}, \\ B_n = \frac{\int_{0}^{1}\cos(x)\sin(n\pi x)dx}{n\pi\int_{0}^{1}\sin^2(n\pi x)dx}. $$