# Finding intersection of two curves using mesh functions

I have the following code which finds intersection of two curves using mesh functions:

y[x_] := x^2
z[x_] := 1
P1 = Plot[y[x], {x, 0, 2}];
P2 = Plot[z[x], {x, 0, 2}];
Test = Show[P1, P2]
GraphicsMeshFindIntersections[Test // DiscretizeGraphics,
GraphicsMeshAllPoints -> False]


This works well in all versions of Mathematica including Mathematica 13.3. But if I modify the code a little bit like this:

y[x_] := x^2
z[x_] := 1
P1 = Plot[y[x], {x, 0, 2}];
P2 = Graphics[{InfiniteLine[{{0, 1}, {2, 1}}]}];
Test = Show[P1, P2]
GraphicsMeshFindIntersections[Test // DiscretizeGraphics,
GraphicsMeshAllPoints -> False]


It works well on all Mathematica versions except Mathematica 13.3. Is this a bug in the latest version?

• It's not a bug if WRI wants to change the behavior of an undocumented function. You really should report it and see what they say. I don't know what GraphicsMeshAllPoints -> False is supposed to do, but the function does not return all point, right? Jan 4 at 7:25
• Both code blocks evaluate in Mathematica v12.2! Jan 4 at 7:44
• suppress PlotHighlighting (new in version 13.3) using P1 = Plot[y[x], {x, 0, 2}, PlotHighlighting -> None]?
– kglr
Jan 4 at 7:47

This maybe works like before:

Block[{Annotation = # &},
GraphicsMeshFindIntersections[Test // DiscretizeGraphics,
GraphicsMeshAllPoints -> False]
]

(* {{0.999811, 1.}} *)


Darned annotations.

My guess is that it's DiscretizeGraphics that behaves different, but prior behavior not given in OP.

• Actually I use it on my Mathematica 13.3 because of this particular reason as mentioned in a previous question : mathematica.stackexchange.com/questions/289187/… Jan 4 at 12:46
• @codebpr Works there, too. See new answer. Jan 4 at 15:49