An archived instance of discourse for discussion in undergraduate PDE.

Yet another heat problem

Mark

Solve the heat problem
$$
\begin{array}{ll}
u_t = u_{xx} & u(x,0) = f(x) \\
u(0,t) = 0 & u(3,t) = 0,
\end{array}
$$
where
$$
f(x) = \left\{
\begin{array}{ll}
0 & \text{if } \; 0\leq x < 1 \\
1 & \text{if } \; 1 \leq x \leq 2 \\
0 & \text{if } \; 2 < x \leq 3.
\end{array}
\right.
$$















qkhan

The solution to this was pretty cool. Here's my attempt at it!

Alright so, since f(x) = 0 when x is between [0, 1) as well as between (2, 3], all you have to do is integrate on the interval [1, 2]. To get L, it's just 2 - 1, which is just one.

I wasn't sure whether this would be a cosine or sine series so I solved for both $a_n$ and $b_n$ and went from there just in case it turned out we'd need both series.

$$a_n = \int_{1}^{2} \cos(n\pi x) dx$$
$$a_n = \frac{\sin(n\pi x)}{n\pi}\bigg|_{x = 1}^{x = 2}$$
$$a_n = \frac{\sin(2n\pi)}{n\pi} - \frac{\sin(n\pi)}{n\pi}$$
But $sin(n\pi)$ always equals zero so there is no $a_n$ term so there is no Fourier cos series which means it's comprised solely of a Fourier sin series.


$$b_n = \int_{1}^{2} \sin(n\pi x) dx$$
$$b_n = - \frac{\cos(n\pi x)}{n\pi}\bigg|_{x = 1}^{x = 2}$$
$$b_n = - \frac{\cos(2n\pi)}{n\pi} + \frac{\cos(n\pi)}{n\pi}$$
$$b_n = \frac{(-1)^n + 1^n}{n\pi}$$


We're almost done, all we're missing is the $\frac{a_0}{2}$ term before we can compile all the pieces together.

$$a_0 = \int_{1}^{2}cos(0)dx$$
$$a_0 = \int_{1}^{2}dx$$
$$a_0 = x\bigg|_{x = 1}^{x =2}$$
$$a_0 = 2 -1 = 1$$
$$\frac{a_0}{2} = \frac{1}{2}$$



So now, putting it all together:
$$1 = \frac{1}{2} + \sum_{n=1}^{\infty} \frac{(-1)^n + 1^n}{n\pi} \sin(n\pi x)$$

To verify, I put it into Mathematica and it was really neat how even though we only integrated on the interval from 1 to 2, the Fourier series is still estimating zero on the intervals [0, 1) and (2, 3]!

f[x_] = (1/2) + Sum[(((-1)^n - (1^n))*Sin[n*Pi*x])/(n*Pi), {n, 1, 20}];
Plot[{f[x], Piecewise[{{1, 1 <= x <= 2}, {0, 0 <= x < 1 || 2 < x <= 3}}]}, {x, 0, 3}]

rjensen

@qkhan

I assumed that since the original Fourier coefficient integral is,

$$a_n = \frac{2}{L}\int_{0}^{3} f(x) \cos(n\pi x) dx$$

then $L$ would be 3 even though the integral part collapses into

$$a_n = \int_{1}^{2} \cos(n\pi x) dx.$$

Even if $L = 1$ I think you should still have a 2 out front for the $\frac{2}{L}$ part? The answer looks good so I don't really know?

qkhan

I was unsure about the 2 honestly but I took it as this is an integral on $[a, b]$ so the numerator is 1 as opposed to the interval $[0, L]$ where the numerator is 2. Not to mention, if you integrate over the interval $[0, 3]$, your L = 3 and that just becomes a nasty problem to solve and I'm not sure how much that changes up the answer since you'd be integrating $\cos\bigg(\frac{n\pi x}{3}\bigg)$. You raise a good point though!

Mark

I liked this a couple of days ago but, as I take a closer look, I think I was thrown off by the nice graph. For a standard heat problem like this, you're going to need to the Fourier sine coefficients - not, the cosine as you've computed. I think you need

$$
\begin{align}
b_n &= \frac{2}{3} \int_0^3 f(x) \sin(n\pi x/3) \, dx \\
&= \frac{2}{3} \int_1^2 \sin(n\pi x/3) \, dx =
\frac{2 \left(\cos \left(\frac{\pi n}{3}\right)-\cos \left(\frac{2 \pi n}{3}\right)\right)}{n\pi}
\end{align}
$$
The solution is thus,
$$
u(x,t) =\frac{2}{\pi } \sum _{n=1}^{\infty } \frac{1}{n}e^{-n^2\pi ^2 t/9} \left(\cos \left(\frac{n \pi }{3}\right)-\cos \left(\frac{2 n \pi
}{3}\right)\right) \sin \left(\frac{n \pi x}{3}\right),
$$
which looks like so: