A question on using Cases [closed]

I am working on Wagon’s FindRoots2D section.

Clear[f];
f[x_, y_] := x – y^2 Cos[y];
g[x_, y_] := -y + x Sin[x];
fcnVec[{x_, y_}] := {f[x, y], g[x, y]};

I am starting (still a rookie) to understand that one can get the data of any object in Mathematica. For example, a contour plot.

cp = ContourPlot[f[x, y] == 0, {x, -10, 10}, {y, -10, 10}]

I’ve learned that if I look at FullForm[cp], I’ll see that the data is using the GraphicsComplex idea, which I have a beginner’s understanding of. If I look at FullForm[Normal[cp]], then I see the Line command using the actual data points instead of indices to the GraphicsComplex data. Now, Stan Wagon uses the Cases command to get those points. I try:

Cases[Normal[cp], Line[z_] :> z]

And I get an empty set. Then I try Stan’s:

Cases[Normal[cp], Line[z_] :> z, ∞]

And I get all of the points. This is where I am stuck. Why does the Infinity symbol make a difference here?

=================

=================

1 Answer
1

=================

The explanation is readily found in the documentation of Cases.

Cases uses standard level specifications
The default value for levelspec in Cases is {1}

The Line expressions are not at level 1, and in fact may be at more than one level. Using ∞ as the level spec tells Cases to look at all levels.

  

 

Thanks for a nice explanation. Very, very helpful.
– David
Jul 19 ’15 at 18:07