I have a list, obtained after differentiating a list of expressions, which contains zeros and symbols, say:
A = {x1^2, x2^2, x3^2, x4^2}
D[A,x3]
results in the list:
{0, 0, 2 x3, 0}
How do I get the position of the non-zero entry, mathematica cannot compare symbols to zero directly. I could convert the elements of the list to strings but is there a faster way?
===
vs==
. Posting your code is also a good idea. $\endgroup$Position[D[A, x3], x_ /; ! TrueQ[x == 0], {1}, Heads -> False]
$\endgroup$Position[D[A, x3], Except[0], 1, Heads -> False]
$\endgroup$ArrayRules[D[A, x3]][[;; -2, 1, 1]]
$\endgroup$