4
$\begingroup$

Let's say I have a following pde:

pde = x^2 u[x, y] D[u[x, y], {x}] + v[x, y] D[u[x, y], {y}]

I want select the dependent variables:

desiredResult = {u[x, y], D[u[x, y], {x}], v[x, y], D[u[x, y], {y}] }

I have tried many things and best result is this one:

depVars = {u, v}.
DeleteDuplicates@Flatten[Cases[pde,
 Derivative[___][#1][___] | #2[___]] & @@@ Subsets[depVars, {2}], 1]

But it works only for those ones, where dependent variables aren't multiplied with some expression. Is there any way to extract all the dependent variables?

$\endgroup$
2
$\begingroup$

How about this?

DeleteDuplicates@
  Cases[pde, Derivative[___][#1][___] | #1[___], Infinity] &@
   (Alternatives @@ depVars)

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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