The question:
The temperatures at ends x = 0 and x= L of a rod length L with insulating sides are held at temperatures $T_1$ and $T_2$ until steady-state conditions prevail. Then, at the instant $t=0$ , the temperatures of the two ends are interchanged. Find the resultant temperature distribution as a function of x and t.
Attempt at a solution:
Our boundary conditions are
$$T(x,0)=\frac{x}{L}(T_1-T_2)+T_2$$
$$T(x=0,t)=T_1$$
$$T(x=L,t)=T_2$$
Using separation of variables, it is trivial to find that $T(x,t)=X(x)\cdot \Theta(t)$ and thus
$$X(x)=A\sin(kx)+B\cos(kx)\,\,\,\,;\,\,\,\Theta(t)=Ce^{-\alpha^2 k^2 t} $$ When we impose the boundary condition on the x-function, though, I find that
When I impose the initial conditions, though, I get
$$X(0)=B=T_1$$
$$X(L)=T_2=A\sin(kx)+T_1\cos(kx)$$
Is my setup correct? Something seems wrong, and I'm a little confused on how to use the boundary conditions.
Thank you in advance.