We are trying to solve the one-dimensional heat equation:
$\frac{\partial u}{\partial t} = k \frac{\partial^{2}u }{\partial x^{2}}$.
The initial condition is:
$u(x,0)= u_{1} $ when $x < 1,$ and $0$ when $x \ge 1$.
The boundary conditions are as follows:
$u(0,t) = \frac{1}{t+a^{-1}}+a$
$u(L,t) = \frac{-1}{t+a^{-1}}+a$
$a$ here is a constant.
We are trying to figure out how to solve this equation. Should we go the Fourier series route to solve this(https://www.youtube.com/watch?v=ToIXSwZ1pJU) or should we do separation of variables?
Best Answer
When solving the homogeneous problem on a finite domain with time dependent boundary conditions you want to get the equilibrium temperature. So if we have
$$\begin{cases} u_{t} = k u_{xx} & 0 \leq x \leq L , t>0 \\ u(x,0) = f(x) , & 0 \leq x \leq L \\ u(0,t) = A(t) , u(L,t) = B(t) & t > 0 \end{cases}$$
In this case we need a candidate solution for the equilibrium temperature so we create a function called the reference temperature, $r(x,t)$ and we want the function to satisfy.
$$ r(0,t) = A(t) \\ r(L,t) = B(t) $$
we can create one like so
$$ r(x,t) = A(t) + \frac{x}{L}\big[B(t) - A(t) \big]$$
Now, instead we have
$$ v(x,t) = u(x,t) - r(x,t) $$
and this solution $v(x,t)$ will solve the homogeneous problem.
Ok, now that it has been set up we'll let
$$ r(x,t) = A(t) + \frac{x}{L}\big[B(t) - A(t) \big]$$
and now we replace $A(t) = \frac{1}{t+a^{-1}} + a$ and $B(t) = \frac{-1}{t+a^{-1}} + a $
$$ r(x,t) = \frac{1}{t+a^{-1}} + a + \frac{x}{L} \big [\frac{-2}{t+a^{-1}} \big]$$
Now, instead we have this homogeneous problem you should be able to solve
$$\begin{cases} v_{t} = k v_{xx} & 0 \leq x \leq L , t>0 \\ v(x,0) = f(x) - r(x) , & 0 \leq x \leq L \\ v(0,t) = 0 , v(L,t) = 0 & t > 0 \end{cases}$$
The solution to this is
$$ v(x,t) = \sum_{i=1}^{\infty} a_{n} \sin(\frac{n \pi x}{L}) e^{-k t(\frac{n \pi}{L})^{2} }$$
you solve for the coefficients $a_{n}$ and we get
$$ a_{n} = \frac{2}{L} \int_{0}^{L} \big[ f(x) - r(x) \big] \sin(\frac{n \pi x}{L}) dx $$
where $f(x)$ is your function
$$ f(x) = \begin{cases} u_{1} & x < 1 \\ 0 & x \geq 1 \end{cases}$$
which looks like the complement of a Heaviside function multiplied by the constant $u_1$. Try that and see what happens.
This about the reference temperature function $r(x,t)$. We need a function such that it obeys the boundary conditions.
If $u(x,t) = v(x,t) + r(x,t)$, we have already said that $v(x,t)$ is the homogeneous solution. So $u(0,t) = v(0,t) + r(0,t)$ and $u(L,t) = v(L,t) + r(L,t)$. But $v(0,t) = 0$ and $v(L,t) = 0$.
$ x = 0$ we get
$$ r(0,t) = A(t) + \frac{0}{L}[B(t) - A(t)] = A(t)$$
and at $x=L$ we have
$$ r(L,t) = A(t) + \frac{L}{L}[B(t) -A(t)] = B(t) + A(t) - A(t) = B(t) $$
which is what we wanted.