I would like to see how many times (and where) the number "91" appear in a set of formulae.
I thought of using Position[expr , 91 , Infinity]
, but it seems not to be working in this simple example:
Position[{Log[Sqrt[1 + I Sqrt[-1 + (4 mm)/91]]]}, 91, ∞]
which gives
{}
Why?
FullForm
of this expression, the91
is embedded insideRational[4,91]
, and it seems like the pattern matcher is treating anything that looks likeRational[_,_]
as atomic (which might or might not be intended behavior). Indeed:Cases[Rational[4, 91], 91, Infinity]
evaluates to{}
. The work-around of Alexei's below is a reasonable hack, although annoying that it must be done. $\endgroup$Cases[Rational[x, 91], 91, Infinity]
evaluates to{91}
, indicating that the pattern matcher sees actual numbers in the formRational[_, _]
as atomic, but if the expression is symbolic, it does not. $\endgroup$Rational[x, 91]
is not an atomic expression, so it is treated differently fromRational[4, 91]
which is atomic. $\endgroup$