Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this partial differential equation (G and M are constants):

enter image description here

and a solution is:

enter image description here

Mathematica doesn't find any solutions. My code for DSolve is:

DSolve[-2*G*M^2*r*Derivative[0, 2][γ][r, z] + 2*G*M^2*Derivative[1, 0][γ][r, z] + 
  2*G*M^2*r*Derivative[2, 0][γ][r, z] == 0, γ[r, z], {r, z}]

and as a result I just got an echo:

enter image description here

Any suggestions? Or nothing can be done in this case?

share|improve this question
Sorry. Now it is working. – Giovanni F. Jul 26 '13 at 1:50
Well, it's not surprising to see that DSolve fails in solving a PDE… – xzczd Jul 26 '13 at 8:47
up vote 6 down vote accepted

Since there doesn't seem to be an easy automated way of solving this partial differential equation in general, it may be worth asking at least for the minimum of manual work required to get a solution. I'll omit the various common constants in the original differential equation because they can be divided out.

From the equation it is pretty obvious that we should expect separation of variables to work (the particular solution g = r^2 + 2z^2 in the question is not of this type, but since there are no boundary conditions specified it seems we should find a set of general solutions). Therefore, I'll guide Mathematica to obtain the separated equations for the z and r coordinates:


equations = -r*Derivative[0, 2][γ][r, z] + 
   Derivative[1, 0][γ][r, z] + 
   r*Derivative[2, 0][γ][r, z] == 0

$r \,\text{g2}(z) \text{g1}''(r)+\text{g2}(z) \text{g1}'(r)-r \,\text{g1}(r) \text{g2}''(z)=0$

γ[r_, z_] := g1[r] g2[z]

separatedEqn = Simplify[Map[#/(r g1[r] g2[z]) &, equations], r > 0]

$\frac{\text{g1}''(r)+\frac{\text{g1}'(r)}{r}} {\text{g1}(r)}=\frac{\text{g2}''(z)}{\text {g2}(z)}$

γ[r, z] /. 
 Flatten@{DSolve[separatedEqn[[1]] == K, g1, r, 
    GeneratedParameters -> CR], 
   DSolve[separatedEqn[[2]] == K, g2, z, GeneratedParameters -> CZ]}

$\left(\text{CZ}(1) e^{\sqrt{K} z}+\text{CZ}(2) e^{-\sqrt{K} z}\right) \left(\text{CR}(1) J_0\left(i \sqrt{K} r\right)+\text{CR}(2) Y_0\left(-i \sqrt{K} r\right)\right)$

Here, K is the separation constant which has to be set equal to the left and right-hand side of separatedEqn by the standard argument of the separation technique: each side manifestly depends only on one of the two independent variables (r or z), and therefore both sides must be equal to a common constant.

The resulting ordinary differential equations with z and r as variables can then be solved with DSolve, leading to four additional integration constants. Since I want to combine the solutions for the factors g1[r] and g2[z], I have to make sure to use different names for the integration constants, which is done using GeneratedParameters.

share|improve this answer
Very nice addition, thanks! – Giovanni F. Jul 27 '13 at 15:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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