I'm trying to understand how Cases
work in Mathematica, and I'm a bit curios why i't wont pick up the Sqrt function?
Consider the following expressions
Cases[Erfc[b], _Erfc, Infinity]
Cases[a*Erfc[b], _Erfc, Infinity]
Cases[a*Sqrt[b], _Sqrt, Infinity]
Cases[a*Sqrt[b], _Sqrt, Infinity]
Cases[a*Sqrt[a]*Erfc[b], _Erfc, Infinity]
Cases[a*Sqrt[a]*Erfc[b], _Sqrt, Infinity]
they give respectively
{}
{Erfc[b]}
{}
{}
{Erfc[b]}
{}
Why does Cases
fail in the cases that give {}
?
FullForm[Sqrt[x]]
. It returnsPower[x, Rational[1, 2]]
which corresponds tox^(1/2)
, and either you have to prevent evaluation or match this form. $\endgroup$