7
$\begingroup$

I'd like to define specific partial derivative operators that change based on if the passed expression is a function of, for example, x vs. xi. I'm not finding anything in the documentation on how to code a check for the expressions dependence. My question is, if given some function f[x,y], how can I check the variables that it depends on?

$\endgroup$
2
  • 3
    $\begingroup$ Possible duplicate of How to define custom differential operator using the arguments of the expression? $\endgroup$
    – Carl Woll
    Sep 5, 2018 at 21:43
  • $\begingroup$ I think it should be possible to also use DownValues[f] to find what the function depends on, since the DownValues has the function signature right there. It just needs to be parsed out and to extract all the symbols from inside f[x_,y_,....] and this part might be tricky to do. ?DownValues $\endgroup$
    – Nasser
    Sep 6, 2018 at 1:50

1 Answer 1

12
$\begingroup$

Perhaps Internal`DependsOnQ:

h = f[x, g[y]];
Internal`DependsOnQ[h, #] & /@ {x, y, g[y], w}

{True, True, True, False}

$\endgroup$

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.