SelectFree2[expr, a, b, ...]
is similar to
SelectFree
but it also differs from the latter in several
respects.
If expr
is a list, SelectFree2
behaves
exactly the same way as SelectFree
.
If expr
is not a list, SelectFree2
first
expands the expression w.r.t. the arguments via
Expand2
.
Furthermore, SelectFree2[a,b]
returns a
and
SelectFree2[a,a]
returns 0
. This differs from
the behavior of SelectFree
but is consistent with the naive
expectations when applying the function to a sum of terms.
Overview, FreeQ2, SelectFree, SelectNotFree, SelectNotFree2.
Note the difference between SelectFree and SelectFree2
[(a + b) c, b] SelectFree
c
[(a + b) c, b] SelectFree2
a c
[a, b] SelectFree
a
[a, b] SelectFree2
a
[a, a] SelectFree
1
[a, a] SelectFree2
0
When there are hidden zeros, SelectFree2
obviously works
better
[(a - b + c)^2 - (a^2 - 2 a b + 2 a c + b^2 - 2 b c + c^2),a] SelectFree
-b^2+2 b c-c^2
[(a - b + c)^2 - (a^2 - 2 a b + 2 a c + b^2 - 2 b c + c^2),a] SelectFree2
0