# Code for solving the heat equation on the semi-infinite rod

Cross posted in mathematica.SE.

Question : I want to test the solution which is given below is right by Matlab/Maple/Mathematica.

Please look the post in mathstackexhange

or

Q: Solve the following heat equation on the semi-infinite rod

$$u_t=ku_{xx}$$ where $x,t>0$ and $u_x(0,t) =0$ and $u(x,0)=\begin{cases} 1, & 0 < x <2 \\ 0, & 2\leq x \end{cases}$

We found the following answer $$u(x,t) = \frac{2}{\pi}\int_{0}^{\infty}e^{-s^2 t}\frac{1-\cos(2s)}{s}\cos(sx)ds.$$