Tag Info

New answers tagged

4

Just 'hiding' heads: fq[ex_, a_, h_] := FreeQ[ex /. h[x__] :> Unique["x"], a], e.g. fq[b^2 + f[a] + g[a, x] + h[b, x, a], , (f | g | h)] yields True


2

[Posting as response per request.] If the goal is to determine a "functional" dependency then the undocumented Internal`DependsOnQ might be a better choice. This function will weed out for example usage within dummy variables in definite Integrate. The indefinite case really should, and does, give dependence. Here is a quick example. expri = ...


9

The functions you are looking for are MemberQ and FreeQ. Both functions take a levelspec and the Option Heads, but the default value for each is different. You can determine if expression x appears anywhere in a using: MemberQ[a, x, {0, -1}, Heads -> True] Or assuming the default option Heads -> True for FreeQ simply: ! FreeQ[a, x]


6

Sorry, after I posted the question, I thought of a trivial solution myself. In case if someone else will have a similar question, here it is: FindVar[expr_, var_] := Module[{temp}, temp = Hold[expr] /. var -> 0; If[temp === Hold[expr], False, True] ]



Top 50 recent answers are included