# Plot of non-homogeneous diffusion equation

Let the initial and boundary value problem for the diffusion heat equation \begin{align*} u_t(x,t)&=u_{xx}(x,t)-\alpha u_x(x,t), \quad 00\\ u(x,0)&=f(x), \quad x\geq 0\\ u(0,t)&=0, \quad t\geq 0\\ \lim_{x\to\infty} u(x,t)&=0 \quad t\geq 0 \end{align*} Set $$u(x,t)=exp[\frac{\alpha}{2}(x-\frac{\alpha}{2}t]w(x,t)$$ and transform the above problem into an equivalent new one with respect to the function $$w(x,t)$$\

First, calculate the derivatives:

\begin{align*} u_t(x,t) &= \exp\left[\frac{\alpha}{2}(x-\frac{\alpha}{2}t)\right]\left(w_t(x,t)-\frac{\alpha^2}{4}w(x,t)\right), \\ u_x(x,t) &= \exp\left[\frac{\alpha}{2}(x-\frac{\alpha}{2}t)\right]\left(w_x(x,t)+\frac{\alpha}{2}w(x,t)\right), \\ u_{xx}(x,t) &= \exp\left[\frac{\alpha}{2}(x-\frac{\alpha}{2}t)\right]\left(w_{xx}(x,t)+\alpha w_x(x,t)+\frac{\alpha^2}{4}w(x,t)\right). \end{align*}

Substitute these back into the PDE:

$$\begin{equation*} u_t(x,t)-u_{xx}(x,t)+\alpha u_x(x,t)=0 \end{equation*}$$

which becomes

\begin{align*} w_t(x,t)-\frac{\alpha^2}{4}w(x,t)-w_{xx}(x,t)-\alpha w_x(x,t)-\frac{\alpha^2}{4}w(x,t)+\alpha w_x(x,t)+\frac{\alpha^2}{2}w(x,t)=0. \end{align*}

This simplifies to:

$$\begin{equation*} w_t(x,t)=w_{xx}(x,t), \quad 00. \end{equation*}$$

Now, we transform the initial and boundary conditions:

$$\begin{equation*} u(x,0)=f(x)=\exp\left[\frac{\alpha x}{2}\right]w(x,0), \quad x\geq 0. \end{equation*}$$

So,

$$\begin{equation*} w(x,0)=\exp\left[-\frac{\alpha x}{2}\right]f(x), \quad x\geq 0. \end{equation*}$$

For the boundary condition at (x=0):

$$\begin{equation*} u(0,t)=0=\exp\left[-\frac{\alpha^2 t}{4}\right]w(0,t), \quad t\geq 0. \end{equation*}$$

Since (\exp\left[-\frac{\alpha^2 t}{4}\right]) is always non-zero, this implies

$$\begin{equation*} w(0,t)=0, \quad t\geq 0. \end{equation*}$$

For the boundary condition at (x\to\infty):

$$\begin{equation*} \lim_{x\to\infty} u(x,t)=0=\exp\left[\frac{\alpha}{2}(x-\frac{\alpha}{2}t)\right]w(x,t), \quad t\geq 0. \end{equation*}$$

This implies

$$\begin{equation*} \lim_{x\to\infty} w(x,t)=0, \quad t\geq 0. \end{equation*}$$

Therefore, the transformed problem is:

\begin{align*} w_t(x,t)&=w_{xx}(x,t), \quad 00\\ w(x,0)&=\exp\left[-\frac{\alpha x}{2}\right]f(x), \quad x\geq 0\\ w(0,t)&=0, \quad t\geq 0\\ \lim_{x\to\infty} w(x,t)&=0, \quad t\geq 0 \end{align*}

This is the heat equation in (w(x,t)) with the transformed initial and boundary conditions.

Now I am trying to solve this using Mathematica

Firstly, we will solve the heat equation with the transformed initial and boundary conditions:

wSolution = DSolveValue[{D[w[x, t], t] == D[w[x, t], {x, 2}],
w[x, 0] == Exp[-alpha*x/2]*f[x], w[0, t] == 0, Limit[w[x, t], x -> Infinity] == 0},
w[x, t], {x, t}]


After obtaining the solution for $$w(x,t)$$ we can use it to calculate u(x,t) using the given transformation:

u[x_, t_] := Exp[alpha/2*(x - alpha*t/2)]*wSolution


Then I tried to plot the solution $$u$$ for f(x)=Exp[-α*x/2] and α=0.5.

alpha = 0.5;
f[x_] := Exp[-alpha*x/2];
wSolution = DSolveValue[{D[w[x, t], t] == D[w[x, t], {x, 2}],
w[x, 0] == f[x], w[0, t] == 0, Limit[w[x, t], x -> Infinity] == 0},
w[x, t], {x, t}]

u[x_, t_] := Exp[alpha/2*(x - alpha*t/2)]*wSolution
Plot[Evaluate[Table[u[x, t], {t, 0, 1, 0.2}]], {x, 0, 10},
PlotLegends -> Table["t = " <> ToString[t], {t, 0, 1, 0.2}]]


And I have this result

What changes do you suggest to my code? Should I try Fourier Transform?

• Already the first step in your calculation fails. The reason is that the boundary condition: Limit[w[x, t], x -> Infinity] == 0is wrong syntax. Jun 10, 2023 at 18:49
• After obtaining the solution for w(x,t) I get no solution in V 13.2.1? !Mathematica graphics as mentioned in your earlier question, you seem not to be checking that the previous command was successful before using its result in next commands. This will make it very hard for you to find where the error came from later in your code. If you check that each step was successful before going to the next one, it will be much easier for you to find such errors. Jun 10, 2023 at 18:49

Try replacing Limit[w[x, t], x -> Infinity] == 0 with w[Infinity, t] == 0 :

alpha = 0.5;
f[x_] := Exp[-alpha*x/2];
wSolution =
DSolveValue[{D[w[x, t], t] == D[w[x, t], {x, 2}],
w[x, 0] == Exp[-alpha*x/2]*f[x], w[0, t] == 0,
w[Infinity, t] == 0}, w[x, t], {x, t}];
u[x_, t_] := Exp[alpha/2*(x - alpha*t/2)]*wSolution;
Plot[Evaluate[Table[u[x, t], {t, 0, 1, 0.2}]], {x, 0, 10},
PlotLegends -> Table["t = " <> ToString[t], {t, 0, 1, 0.2}]]