# Partial differential equation heat/diffusion equation 3d

I'm trying to solve the heat/diffusion equation in 3d in spherical symmetry $$\partial_t f=D\Delta f$$. I wrote :

DSolve[{D[f[x, t], t] == Laplacian[f[x, t], {x, y, z}, "Spherical"],f[R,t]==C0,f[Infinity,t]==C1}, f, {x, t}]


But Mathematica doesn't manage to do it. I know that the solution is something like $$f(r,t)=a(1+b \, erfc(\sqrt{r/Dt})/r)$$, but I'd like to solve it with Mathematica. How could I do ?

• Perhaps Mathematica misses initial&boundary conditions? – Ulrich Neumann Jan 29 '19 at 10:41
• Still missing initial conditions. By the way, I think MMA cannot handle Infinity-boundary conditions. – Ulrich Neumann Jan 29 '19 at 11:05

Still, you need an initial condition to determine a particular solution, but it's not the main issue here. As already mentioned in the comment, DSolve just can't handle boundary condition at infinity, at least now, in most cases (see the comment below for an exception). Here I'll give a solution based on Laplace transform, with initial condition f[x,0] == C1:

{eq, ic, bc} = {D[f[x, t], t] == Laplacian[f[x, t], {x, y, z}, "Spherical"],
f[x, 0] == C1, {f[R, t] == C0, f[inf, t] == C1}};

tset = LaplaceTransform[{eq, bc[[1]]}, t, s] /. Rule @@ ic /.
HoldPattern@LaplaceTransform[a_, __] :> a;

tsol = DSolve[tset, f[x, t], x][[1, 1, -1]];

Collect[tsol // Expand, Exp[Sqrt[s] x]]
(* C1/s + (E^(-Sqrt[s] x) C[1])/x +
E^(Sqrt[s] x) ((C0 E^(-R Sqrt[s]) R)/(s x) - (C1 E^(-R Sqrt[s]) R)/(s x) - (
E^(-2 R Sqrt[s]) C[1])/x) *)


It's easy to notice that, the coefficient of E^(Sqrt[s] x) should be 0, or the boundary condition at infinity won't be satisfied:

const =
Solve[(C0 E^(-R Sqrt[s]) R)/(s x) - (C1 E^(-R Sqrt[s]) R)/(s x) - (
E^(-2 R Sqrt[s]) C[1])/x == 0, C[1]][[1]]
(* {C[1] -> ((C0 - C1) E^(R Sqrt[s]) R)/s} *)


Finally we find the solution by transforming back:

sol = InverseLaplaceTransform[tsol /. const, s, t]
(* ConditionalExpression[-((-C0 R +
C1 (R - x) + (-C0 + C1) R Erf[(R - x)/(2 Sqrt[t])])/x), R < x] *)

• nice solution. But you said DSolve just can't handle boundary condition at infinity, well, sometimes it can. But most of the times it can't. Here is example of one with BC at infinity that Mathematica can solve: ClearAll[f,t,x]; pde=I*D[f[x,t],t]==-D[f[x,t],{x,2}]+2*x^2*f[x,t]; bc={f[-Infinity,t]==0,f[Infinity,t]==0}; sol=DSolve[{pde,bc},f[x,t],{x,t}] which gives !Mathematica graphics – Nasser Jan 29 '19 at 11:48
• @Nasser Interesting! But… is it reliable? (You know, solution for PDE with b.c. at infinity isn't expressed as series, in many cases. ) – xzczd Jan 29 '19 at 12:00