2
$\begingroup$

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}]

enter image description here

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?

$\endgroup$

closed as off-topic by Bob Hanlon, MarcoB, m_goldberg, Dr. belisarius, dr.blochwave Jul 20 '15 at 8:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Bob Hanlon, MarcoB, m_goldberg, Dr. belisarius, dr.blochwave
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ BTW, have you seen this? $\endgroup$ – J. M. will be back soon Jul 19 '15 at 16:40
  • 1
    $\begingroup$ The third argument is a level specification, as noted in the docs for Cases[]. In this case, is short for "as deep as you can go". $\endgroup$ – J. M. will be back soon Jul 19 '15 at 16:44
  • $\begingroup$ @J. M. Great link to study. Thanks so much. $\endgroup$ – David Jul 19 '15 at 18:08
6
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Thanks for a nice explanation. Very, very helpful. $\endgroup$ – David Jul 19 '15 at 18:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.