Heat Equation with Zero-Temperature Boundaries (Continued)

A few entries ago, I concluded that the solution to the heat equation was$$u(x,t)=\sum_{n=1}^{\infty}B_n\sin\left(\frac{n\pi x}{L}\right)e^{-k(n\pi/L)^2t}.$$However, I didn't know how to determine what each $B_n$ is. Luckily, an idea claims that$$\int_0^L\sin\left(\frac{n\pi x}{L}\right)\sin\left(\frac{m\pi x}{L}\right)\,dx=\frac{L}{2},$$by orthogonality. Then, applying the initial condition $u(x,0)=f(x)$, I observe that$$f(x)=\sum_{n=1}^{\infty}B_n\sin\left(\frac{n\pi x}{L}\right).$$Finally, multiplying both sides by $\sin(m\pi x/L)$ and integrating from $0$ to $L$ gives$$B_m=\frac{2}{L}\int_0^Lf(x)\sin\left(\frac{m\pi x}{L}\right)\,dx.$$The solution to the heat equation is now complete. Let's then solve a real-life application:

Problem

Suppose that I have a metal rod of length $30$ centimeters with its lateral surface insulated. I heat it up to $100$ degrees Celsius uniformly and cool its ends down to $0$ degrees. What function models the rod's temperature distribution at $t=5$ seconds? Assume the rod to have thermal diffusivity $k=20\text{ cm}^2/s$ .

Solution

We have the following PDE:\begin{align}\frac{\partial u}{\partial t}&=20\frac{\partial^2u}{\partial x^2},\\u(0,t)&=0,\\u(30,t)&=0,\\u(x,0)&=100.\end{align}Then its solution has the following approximation:$$\begin{align}B_1&=\frac{20}{3}\int_0^{30}\sin\left(\frac{\pi x}{30}\right)\,dx=\frac{400}{\pi},\\u(x,5)&\approx\frac{400}{\pi}\sin\left(\frac{\pi x}{30}\right)e^{-1/9\pi^2}.\end{align}$$Letting $t$ be arbitrary, this is what we have visually:


3-D and Contour Views
The approximation to the solution is due to my current inability to compute Fourier series. Hopefully, in the next entry, I'll know how to compute the convergence of those infinite sums. Also, I can't wait to study both Einstein's and Schrödinger's equations.