I'm trying to solve a 2D PDE with homogeneous Dirichlet boundary condition.

The problem I'm actually trying to solve is a bit more complicated, but I came up with a reduced version just to get DSolve "up and running":

$$\begin{aligned}\mathbf{x} \cdot \nabla f(\mathbf{x})&=f(\mathbf{x}) ~~~~~~~ \mathbf{x} \in D \\ f(\mathbf{x}) &= 0, ~~~~~~~~~~~ \mathbf{x} \in \partial D\end{aligned}$$

where $D$ is the (open) unit disk in $\mathbb{R}^2$.

In Mathematica, I have tried

DSolve[{Dot[{x, y}, Grad[f[x, y], {x, y}]] == f[x, y], 
  DirichletCondition[f[x, y] == 0, True]}, 
 f[x, y], {x, y} \[Element] Disk[{0, 0}, 1]]

but this simply just prints

RowBox[{"0", ",", "1"}], ")"}],
MultilineFunction->None]\)[x, y] + x 
RowBox[{"1", ",", "0"}], ")"}],
MultilineFunction->None]\)[x, y] == f[x, y], 
  DirichletCondition[f[x, y] == 0, True]}, 
 f[x, y], {x, y} \[Element] Disk[{0, 0}, 1]]

immediately without any apparent attempt to solve the system.

  • 1
    $\begingroup$ I do not think you can use dirichletcondition with DSolve. see how-to-use-dirichletcondition-with-dsolve-and-not-just-ndsolvevalue I also do not think you can use \[Element] Disk[{0, 0}, 1] with DSolve. These work with NDSolve. I have not seen a DSolve example that works with them so far. Also, you might have better chance writing/converting the PDE to polar coordinates since you are on a disk geometry. $\endgroup$
    – Nasser
    Apr 28, 2022 at 19:54
  • $\begingroup$ btw, if the solution is zero at boundary (edge of the disk) as you say, then the solution will be zero everywhere. Nothing to solve. I verified this by solving the pde in polar coordinates and that Mathematica says also. One can see that f=0 satisfies the PDE and the BC also. $\endgroup$
    – Nasser
    Apr 28, 2022 at 22:44
  • $\begingroup$ Point is, changing to polar coordinates, and giving an explicit value of f at boundary at specific distance (i.e. specific value of r), DSolve was now able to solve the PDE. $\endgroup$
    – Nasser
    Apr 28, 2022 at 22:49
  • $\begingroup$ if numerical solution is sufficient NDSolve works as expected. $\endgroup$ Apr 29, 2022 at 6:23

1 Answer 1


Here is the analytical solution for the PDE you show. The PDE is converted to polar. Used Maple since I do not feel like doing this by hand now.


 Dot[{x, y}, Grad[f[x, y], {x, y}]]


Mathematica graphics



Which gives

= f(r,theta)

In Latex, the above is

$$ \sin \! \left(\theta \right) \left(\left(\frac{\partial}{\partial r}f \! \left(r , \theta \right)\right) \sin \! \left(\theta \right) r +\left(\frac{\partial}{\partial \theta}f \! \left(r , \theta \right)\right) \cos \! \left(\theta \right)\right)+\cos \! \left(\theta \right) \left(\left(\frac{\partial}{\partial r}f \! \left(r , \theta \right)\right) \cos \! \left(\theta \right) r -\left(\frac{\partial}{\partial \theta}f \! \left(r , \theta \right)\right) \sin \! \left(\theta \right)\right) = f \! \left(r , \theta \right) $$

Entered this into Mathematica DSolve, for unit disk (i.e. $r=1$) and got

ClearAll[r, theta, f]
pdeInPolar = 
  Sin[theta]*(D[f[r, theta], r]*Sin[theta]*r + 
       D[f[r, theta], theta]*Cos[theta]) + 
    Cos[theta]*(D[f[r, theta], r]*Cos[theta]*r - 
       D[f[r, theta], theta]*Sin[theta]) == f[r, theta];
bc = f[1, theta] == 0;
DSolve[{pdeInPolar, bc}, f[r, theta], {r, theta}, 
 Assumptions -> 0 < r < 1]

Mathematica graphics

Compare to numerical

ClearAll[x, y, f];
pde = Dot[{x, y}, Grad[f[x, y], {x, y}]] == f[x, y];
bc = DirichletCondition[f[x, y] == 0, True];
sol = NDSolveValue[{pde, bc}, f, {x, y} \[Element] Disk[{0, 0}, 1]];
Plot3D[sol[x, y], {x, -1, 1}, {y, -1, 1}]

Mathematica graphics

  • $\begingroup$ Thank you, I will try to apply this to my real problem (that does not have a trivial solution!). $\endgroup$ Apr 29, 2022 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.