I am trying to solve the following problem:
$$\dfrac{\partial{\phi}}{\partial{t}} = \dfrac{\partial^2{\phi}}{\partial{x}^2} - \cos(x), \ x > 0, t > 0$$
$$\phi(x, 0) = 0, \ x > 0$$
$$\phi(0, t) = e^{-t}, \ t > 0$$
Taking the Laplace transform (in $t$, of course) gives
$$\mathcal{L} \left\{ \dfrac{\partial{\phi}}{\partial{t}} \right\} = \mathcal{L} \left\{ \dfrac{\partial^2{\phi}}{\partial{x}^2} - \cos(x) \right\}$$
$$\therefore s \mathcal{L}\{\phi\} - \phi(0) = \dfrac{d^2 \mathcal{L} \{ \phi \}}{dx^2} - \dfrac{\cos(x)}{s}$$
And since $\phi(x, 0) = 0$, we have
$$s \mathcal{L} \{ \phi \} = \dfrac{d^2 \mathcal{L} \{ \phi \}}{dx^2} - \dfrac{\cos(x)}{s}$$
This is an ODE with constant coefficients.
From now on, let $\mathcal{L}\{ \phi \} = \bar{\phi}$ (for the sake of conciseness).
So our constant-coefficient ODE is
$$\dfrac{d^2 \bar{\phi}}{dx^2} - s \bar{\phi} = \dfrac{\cos(x)}{s}$$
This is a inhomogeneous ODE and, judging by the inhomogeneous term $\dfrac{\cos(x)}{s}$, can be solved using the method of undetermined coefficients.
The homogeneous version of the ODE is
$$\dfrac{d^2 \bar{\phi}}{dx^2} - s \bar{\phi} = 0$$
The characteristic polynomial is
$$m^2 - s = 0$$
$$\therefore m = \pm \sqrt{s}$$
Therefore, the complementary equation for this inhomogeneous ODE is
$$y_c(x) = Ae^{x\sqrt{s}} + Be^{-x\sqrt{s}}$$
And our particular solution for this inhomogeneous ODE is
$$y_p(x) = -\dfrac{1}{s^2 - s} \cos(x)$$
Therefore, our solution to the inhomogeneous ODE is
$$y(x) = Ae^{x\sqrt{s}} + Be^{-x\sqrt{s}} - \dfrac{1}{s^2 - s} \cos(x)$$
Therefore, we have that
$$\bar{\phi}(x, s) = Ae^{x\sqrt{s}} + Be^{-x\sqrt{s}} - \dfrac{1}{s^2 - s} \cos(x)$$
Here is where I am stumped.
HOWEVER, one way that I have seen other problems proceed is by assuming another boundary condition:
$$\lim\limits_{x \to \infty} \phi(x, t) = 0$$
This makes sense from a physical standpoint, but it was not specified in the problem statement, so I am unsure if it is valid for me to use it?
Also, I don't have full solutions for these problems, so I have no way of checking the intermediate steps.
The final solution should be
$$\phi(x, t) = \text{erfc}\left( \dfrac{x}{2\sqrt{t}} \right) - \cos(1 - e^{-t})$$
I would greatly appreciate it if people could please help me solve this problem.
EDIT: If we proceed with assuming the extra boundary condition (that is, if we proceed with assuming that $\lim\limits_{x \to \infty} \phi(x, t) = 0$), then we continue from above as follows:
Now, since $\lim\limits_{x \to \infty} \phi(x, t) = 0$, we have that $Ae^{-x \sqrt{s}} = \dfrac{A}{e^{x \sqrt{s}}} \to 0$ as $x \to \infty$, and $- \dfrac{1}{s^2 - s} \cos(x)$ does not exist as $x \to \infty$, since $\cos(x)$ will not converge.
So what do we do from here? It seems that the $- \dfrac{1}{s^2 - s} \cos(x)$ term is causing us problems?
IGNORE EVERYTHING BELOW THIS POINT
$$\bar{\phi}(x, s) = \int_0^\infty \phi(x, t) e^{-st} \ dt,$$
we have that $\bar{\phi}(x, s) \to 0$ as $x \to \infty$, and hence $B = 0$, since $Ae^{-x \sqrt{s}} = \dfrac{A}{e^{x \sqrt{s}}} \to 0$ as $x \to \infty$.
Therefore, we now have
$$\bar{\phi}(x, s) = Ae^{-x \sqrt{s}}.$$
We now use the given boundary conditions.
Letting $x = 0$ in the Laplace transform of $\phi$ gives
$$\bar{\phi}(0, s) = \int_0^\infty \phi(0, t)e^{-st} \ dt = \int_0^\infty e^{-t}e^{-st} \ dt = \int_0^\infty e^{-t(1 + s)} \ dt$$
$$= \dfrac{-1}{1 + s} \int_0^{-\infty} e^u \ du = \dfrac{1}{1 + s},$$
since $\phi(0, t) = e^{-t}$ for all $t > 0$.
Let $\Phi(s,x)=\int_{0}^{\infty}\phi(t,x)e^{-st}dt$ be the Laplace transform in time of the desired solution. Then the transform of the heat equation is $$ \int_{0}^{\infty}e^{-st}\frac{\partial\phi}{\partial t}dt =\int_{0}^{\infty}e^{-st}\frac{\partial^2\phi}{\partial x^2}dt-\cos(x)\int_{0}^{\infty}e^{-st}dt. $$ Expanding this out gives $$ e^{-st}\phi(t,x)|_{t=0}^{\infty}-\int_{0}^{\infty}(-se^{-st})\phi(t,x)dt \\ =\frac{\partial^2}{\partial x^2}\int_{0}^{\infty}e^{-st}\phi(t,x)dt-\left.\cos(x)\frac{e^{-st}}{-s}\right|_{t=0}^{\infty}. $$
Therefore, $$ -\phi(0,x)+s\int_{0}^{\infty}e^{-st}\phi(t,x)dt=\frac{\partial^2}{\partial x^2}\int_{0}^{\infty}e^{-st}\phi(t,x)dt-\frac{\cos(x)}{s}. $$
Let $\Phi(s,x)=\int_{0}^{\infty}e^{-st}\phi(t,x)dt$. Then $\phi(0,x)=0$ gives
$$ s\Phi(s,x)=\Phi_{xx}(s,x)-\frac{\cos(x)}{s} \\ \Phi_{xx}-s\Phi=\frac{\cos(x)}{s}. $$ A particular solution is $C\cos(x)$. But $\cos''=-\cos$, which gives $C(-1-s)=1/s$ or $C=-1/(s(1+s))$. So the general solution is
$$ \Phi(s,x)=A\cos(\sqrt{s}x)+B\sin(\sqrt{s}x)-\frac{\cos(x)}{s(1+s)}. $$ Now you have to transform back in $s$.