I want to solve this PDE. I have tried to solve it with NDSolve but found error 'Boundary values may only be specified for one independent variable. Initial values may only be specified at one value of the other independent'. Please help me to solve this problem: I am beginner in Mathematica. This is cylinderical PDE and in equation omega, lambda and fi have constant values i.e 2,3,4

This is what I have tried.

sol = NDSolve[{w^2 (1/p) (D[T[p, x] (D[T[p, x], {p, 1}]), {p, 1}]) 
      + D[T[p, x], {x, 2}] - 2 l (D[T[p, x], {x, 1}]) - 4 f^2 (T[p, x]) == 0,
T[p, 0] == 1, T[p, 1] == 1, T[0, x] == 10, T[1, x] == 1}, 
{T[p, x]}, {p, 0, 1}, {x, 0, 1}] 
  • 1
    $\begingroup$ You might have a look at this, though the answer might change within the month. In the meantime, you might look into formatting on this site. $\endgroup$ Commented Apr 30, 2014 at 20:50
  • 1
    $\begingroup$ Please post you (eventually non-working) code $\endgroup$ Commented Apr 30, 2014 at 20:51
  • 1
    $\begingroup$ sol = NDSolve[{w^2 (1/p) (D[T[p, x] (D[T[p, x], {p, 1}]), {p, 1}]) + D[T[p, x], {x, 2}] - 2 l (D[T[p, x], {x, 1}]) - 4 f^2 (T[p, x]) == 0, T[p, 0] == 1, T[p, 1] == 1, T[0, x] == 10, T[1, x] == 1}, {T[p, x]}, {p, 0, 1}, {x, 0, 1}] $\endgroup$
    – Umer
    Commented Apr 30, 2014 at 21:10
  • $\begingroup$ @Umer this does not seem to work? $\endgroup$
    – chris
    Commented May 1, 2014 at 10:09
  • $\begingroup$ thank you everyone for commenting. my codes are not working but now i am trying to solve it analytically as jens has mentioned. i wish i could do it numerically. $\endgroup$
    – Umer
    Commented May 1, 2014 at 10:28

1 Answer 1


As this is a separable problem, I would suggest doing the entire solution analytically instead of numerically. The separation of variables can be performed along the same lines as in this closely related answer. I had to modify the steps slightly to get the variables r and x to separate properly, so I'll list the steps here.

First define the PDE and the separation ansatz. In pde2, I use Expand to get additional cancellations that Simplify alone doesn't achieve.

To enforce the boundary conditions, I use Solve after determining the general solution to each separated function (which are called ax[x] and ar[r] here). The separation constant is called $\kappa^2$ in this calculation:

pde = Function[
   c, ω^2 (D[c, {r, 2}] + D[c, r]/r) + D[c, {x, 2}] - 
    2 λ D[c, x] - 4 ϕ^2 c];

ansatz = ar[r] ax[x];

pde2 = Expand[Apply[Subtract, pde[ansatz]/ansatz == 0]]

$$\frac{\omega ^2 \text{ar}''(r)}{\text{ar}(r)}+\frac{\omega ^2 \text{ar}'(r)}{r \text{ar}(r)}+\frac{\text{ax}''(x)}{\text{ax} (x)}-\frac{2 \lambda \text{ax}'(x)}{\text{ax}(x)}-4 \phi^2$$

ar[r] /. First@
  DSolve[Select[pde2, D[#, x] == 0 &] == κ^2, ar[r], r]

BesselJ[0, (I r Sqrt[4 k^2 + κ^2])/ω] C[1] + 
 BesselY[0, -((I r Sqrt[4 k^2 + κ^2])/ω)] C[2]

rSolution[r_] = % /. C[2] -> 0

(* ==> BesselJ[0, (I r Sqrt[4 k^2 + κ^2])/ω] C[1] *)

rCoefficients = First@Solve[rSolution[1] == 1, C[1]];

xSolution[x_] = ax[x] /. First@DSolve[
    Select[pde2, D[#, x] =!= 0 &] == -κ^2, ax[x], x, 
    GeneratedParameters -> B]

E^(x (λ - Sqrt[-κ^2 + λ^2])) B[1] + 
 E^(x (λ + Sqrt[-κ^2 + λ^2])) B[2]

xCoefficients = 
 First@Solve[xSolution[0] == 1 && xSolution[1] == 1, {B[1], B[2]}];

generalSolution[r_, x_] = 
 Simplify[rSolution[r] xSolution[x] /. xCoefficients /. rCoefficients]

$$\frac{e^{(x-1) \left(-\sqrt{\lambda ^2-\kappa ^2}\right)-\lambda } \left(e^{\sqrt{\lambda ^2-\kappa ^2}+\lambda +\lambda x}+e^{x \left(2 \sqrt{\lambda ^2-\kappa ^2}+\lambda \right)}-e^{(2 x-1) \sqrt{\lambda ^2-\kappa ^2}+\lambda (x+1)}-e^{\lambda x}\right) J_0\left(\frac{i r \sqrt{4 k^2+\kappa ^2}}{\omega }\right)}{\left(e^{2 \sqrt{\lambda ^2-\kappa ^2}}-1\right) J_0\left(\frac{i \sqrt{4 k^2+\kappa ^2}}{\omega }\right)}$$

FullSimplify[pde[generalSolution[r, x]] == 0]

(* ==> True *)

In the expression pde2, selecting the terms that depend on one or the other variable has to be done with care, since there is also a term that doesn't depend on either of the variables ($-4\phi^2$). So instead of going with FreeQ to determine whether a variable occurs, I test for the derivatives of each term with respect to a given variable. That way, in Select[pde2, D[#, x] =!= 0 &] I only collect terms that really depend on x, whereas in Select[pde2,D[#,x]==0&] I include terms that depend on r or are constant.

  • $\begingroup$ Nice! It would be cool to write a wrapper to do this generically (i.e. as a possible attempt for an arbitrary PDE)? $\endgroup$
    – chris
    Commented May 1, 2014 at 10:11
  • $\begingroup$ thanks @jens is there any way to solve it numerically like using finite differences (method of lines)? $\endgroup$
    – Umer
    Commented May 1, 2014 at 10:30
  • $\begingroup$ @chris That may be possible - although in general it may need more steps to insure that Mathematica multiplies by the correct powers of the independent variables to get the equivalent of pde2. I did manage to make it work in parabolic cylinder coordinates, so maybe I'll post an expanded version later. $\endgroup$
    – Jens
    Commented May 1, 2014 at 15:12
  • $\begingroup$ What would be even nicer would be that the interpreter tries separating the problem in various coordinates. (though I guess the sets of possible coordinates depends on the geometry of the boundary condition). It just seems to me a more desirable feature for future versions of mathematica than some esoteric thing that have been introduced. $\endgroup$
    – chris
    Commented May 1, 2014 at 15:16
  • $\begingroup$ @Umer The problem is that you require boundary conditions on both ends of both intervals for your variables. The method of lines works only when you pose initial conditions, it doesn't know how to aim for the correct final condition. $\endgroup$
    – Jens
    Commented May 1, 2014 at 15: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.