# Solving two PDEs with common IC and BCs

I'm new to Mathematica and want to try it after MATLAB.

I want to solve two different PDEs using the same initial condition and boundary conditions.

(want to verify that the solution I got using separation of variables is the same).

The PDEs I want to solve are:

$$\frac{\partial u}{\partial t} = \frac{1}{x}\frac{\partial}{\partial x} \bigg( x \frac{\partial u}{\partial x} \bigg)$$

$$\frac{\partial u}{\partial t} = \frac{1}{x^2}\frac{\partial}{\partial x} \bigg( x^2 \frac{\partial u}{\partial x} \bigg)$$

The initial condition is:

$$\qquad u(x,0) = 0$$

The boundary conditions are:

$$\qquad \lim_{x\rightarrow 0 } \frac{\partial u}{\partial x} = 0$$ $\qquad u(1,t) = 1$\$

Here's what I attempted:

heqn1 = D[u[x, t], t] == (1/x)*D[[x,t],x]*(x*D[u[x, t], x]);
heqn2 = D[u[x, t], t] == (1/x^2)*D[[x,t],x]*D[u[x, t], x];
ic = u(x,0) == 0;
bc = {D[u[0, t], x] == 0, u[1, t] == 1};
sol1 = DSolve[{heqn1, bc, ic}, u, {x, t}] /. {K[1] -> m}
sol2 = DSolve[{heqn2, bc, ic}, u, {x, t}] /. {K[1] -> m}


Could someone help me fix this?

• Your code does not correspond to the equations shown. For example, heqn1 should be defined as heqn1 = D[u[x, t], t] == (1/x)*D[x*D[u[x, t], x], x]; Commented Jan 5, 2021 at 6:33
• Change initial conditions to ic = u[x, 0] == 0  Commented Jan 5, 2021 at 7:05
• D[u[0, t], x] is wrong. You ma write this e.g. D[u[x0,t],x0]/.x0->0 Commented Jan 5, 2021 at 9:38
• Are you interested in symbolic solution only, or you just want to verify the solution you got using separation of variables? If the latter, an you add that solution? Commented Jan 6, 2021 at 4:27

One way is solve numerically, for first equation (you must edit code for second equation and works to):

sol = NDSolve[{D[u[x, t], t] - (1/x)*D[x*D[u[x, t], x], x] ==
NeumannValue[0, x == 0], DirichletCondition[u[x, t] == 1, x == 1],
DirichletCondition[u[x, t] == 0, t == 0]},
u, {x, 0, 1}, {t, 0, 1},
Method -> {"FiniteElement",
"MeshOptions" -> {"MaxCellMeasure" -> 0.00001}}](*NDSolve spit out some errors but you can ignore it.*)

Plot[Table[u[x, t] /. sol, {x, 0, 1, 1/25}] // Evaluate, {t, 0, 1}, PlotRange -> All]
Plot3D[u[x, t] /. sol, {x, 0, 1}, {t, 0, 1}, AxesLabel -> Automatic,
PlotRange -> All, PlotPoints -> 100]


I checked with Maple 2020.2 and the solution are almost exact (to my eye the surface is very similar :)).