# Removing {0,0,0} from expression

I have an expression that results in something like this:

Subscript[A, 1] +
Subscript[x,
3] (Subscript[A, 1] Subscript[k, 11] + {0, 0, 0}[Subscript[x, 1],
Subscript[x, 2]]


For simplicity's sake,

out:= A1+x3(A1K11+ {0,0,0}[x1,x2])


All numbers are subscripts. I know that {0,0,0}[x1,x2] =0 How can I tell that to Mathematica? there are multiple instances of the same in my program so a general fix would be ideal. Reiterating, I want to replace all instances of {0,0,0}[x1,xx2] with a zero

• exp = Subscript[A, 1] + Subscript[x, 3] (Subscript[A, 1] Subscript[k, 11] + {0, 0, 0}[Subscript[x, 1], Subscript[x, 2]]); exp /. {0, 0, 0}[__] :> 0?
– kglr
Dec 28, 2017 at 10:22
• TIP: never use Subscript. Dec 28, 2017 at 16:18

In your case, you can match the {0,0,0} exactly. Therefore, you can use replacements or DeleteCases:

expr = Subscript[A, 1] +
Subscript[x,
3] (Subscript[A, 1] Subscript[k, 11] + {0, 0, 0}[Subscript[x, 1],
Subscript[x, 2]])

expr /. {0, 0, 0}[___] :> 0

DeleteCases[expr, {0, 0, 0}[___], Infinity]


If you want to generalize this, you just have to ask yourself, how should the pattern look. For instance, let's say you have cases like {0,0,1} and {1,0,3} and you want to delete them as well, then you can make your matching broader by using:

{_Integer, _Integer, _Integer}[___] :> 0


The rule above reads as follow: Replace everything with 0 that has a list of 3 integers in the front, followed by anything or nothing at all in brackets (that is what ___ stands for).

• How can I use Replacements? I have a similar problem with a case that's {0,0,1} instead of {0,0,0}. I'd like to understand a general method. thanks Dec 28, 2017 at 13:05

Also

expr /. {0 ..} -> (0 &)
% // TeXForm


$A_1 k_{11} x_3+A_1$

• ... assuming, of course, that {0,0,0} appears only in the form {0,0,0}[somethings] in expr.
– kglr
Dec 28, 2017 at 10:51
• How would I do the same for {0,0,1}[ ___]? Dec 28, 2017 at 11:44
• @Ashwin, you can use {0,0,1}->(0&) (again if {0,0,1} appears only as {0,01}[...])
– kglr
Dec 28, 2017 at 18:52