I am using FreeQ to define a replacement rule. However, it doesn't seem to be possible to specify a list of variables as the second argument, which is why I came up with something like this

AngleBracket[a_ b_] := 
 a AngleBracket[b] /; (FreeQ[a, x] && FreeQ[a, y] && FreeQ[a, z])

Now, for many variables x,y,z, ... this becomes very tedious. Is there a better, i.e., shorter way to achieve what I want?


closed as off-topic by Daniel Lichtblau, MarcoB, Alex Trounev, José Antonio Díaz Navas, bbgodfrey Feb 19 at 12:17

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, MarcoB, Alex Trounev, José Antonio Díaz Navas, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    $\begingroup$ use Alternatives , i.e., FreeQ[a, x|y|z]? $\endgroup$ – kglr Feb 8 at 10:13
  • $\begingroup$ Ah, I wasn't ware of Alternatives, thx. Just thought now about sth like this Apply[And, FreeQ[a, #] & /@ {x, y, z}], but this is also rather dirty. $\endgroup$ – Display Name Feb 8 at 10:15
  • $\begingroup$ If you have a list of variables, you can do something along the lines of FreeQ[a, Alternatives@@{x, y, z, f, g, h, j ...}] $\endgroup$ – Carl Lange Feb 10 at 15:37
list = {x,y,z};

You can use Alternatives@@list as the second argument of FreeQ:

FreeQ[x + 2 y + w, Alternatives @@ {x, y, z}]


FreeQ[5 + u v w, Alternatives @@ list]


Alternatively, you can map FreeQ[a, #]& on list:

And @@ (FreeQ[x + 2 y + w, #] & /@ list)


And @@ (FreeQ[5 + u v w, #] & /@ list)



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