# Detecting PlusMinus in an expression

FreeQ and MemberQ keep telling me that the expression is incomplete when I want to check if \[PlusMinus] is present in an expression. Any ideas for a work around? Thanks

• Post an example – Marius Ladegård Meyer Oct 19 '17 at 11:10
• Could you give an example expression with [PlusMinus]. – Sumit Oct 19 '17 at 11:10
• FreeQ[expression, _PlusMinus] or FreeQ[expression, a_ ± b_]? – kglr Oct 19 '17 at 11:19
• Yes kglr, that's it. I was missing underscore before term. Many thanks. – Rupert Gillyweed Oct 19 '17 at 11:24

expressions = {±2, ±2 + xyz,  x y z, x PlusMinus[a, b], 3 ± 5}


{±2, xyz + ±2, x y z, x (a ± b), 3 ± 5}

FreeQ[#, PlusMinus] & /@ expressions


{False, False, True, False, False}

FreeQ[#, _PlusMinus] & /@ expressions


{False, False, True, False, False}

FreeQ[#, PlusMinus[__]] & /@ expressions


{False, False, True, False, False}

FreeQ[#, ___ ± ___] & /@ expressions


{False, False, True, False, False}

FreeQ[#, _ ± _] & /@ expressions


{True, True, True, False, False}

For any question like "Detecting ... in an expression", the first thing you should do is look at the FullForm of a simple example. In your case, something like:

FullForm[a ± b]


PlusMinus[a,b]

would show you that you need to look for the head PlusMinus, and not the character $\pm$.

FreeQ[\[PlusMinus]2, _PlusMinus]

• What about clarifying the question? – Kuba Oct 19 '17 at 11:56