Find intersections points with axes - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-09-21T14:04:10Z https://mathematica.stackexchange.com/feeds/question/100098 https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/100098 1 Find intersections points with axes Vaggelis_Z https://mathematica.stackexchange.com/users/5052 2015-11-21T17:58:33Z 2015-11-23T01:15:45Z <p>Let's create some points corresponding to a simple closed curve</p> <pre><code>C0 = ContourPlot[x^2/4 + y^2/9 == 1, {x, -5, 5}, {y, -5, 5}, PlotPoints -&gt; 100]; data = C0[[1, 1]]; S0 = ListPlot[data, PlotStyle -&gt; {Blue, PointSize[0.005]}] </code></pre> <p><a href="https://i.stack.imgur.com/bdvkG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bdvkG.jpg" alt="enter image description here"></a></p> <p>Now I would like to find the intersection points with the two axes. In this example the solutions should be $x = \pm 2$ and $y = \pm 3$.</p> <p><strong>IMPORTANT NOTE:</strong> The real data file corresponds to a closed curve with unknown analytical equation, so in the suggested solution you should not take into account the equation of the ellipse, only <code>data</code> is known.</p> <p>Many thanks in advance.</p> https://mathematica.stackexchange.com/questions/100098/-/100112#100112 5 Answer by Peter Roberge for Find intersections points with axes Peter Roberge https://mathematica.stackexchange.com/users/22083 2015-11-21T19:05:58Z 2015-11-23T01:15:45Z <p>Get rid of duplicate x values we can feed to an interpolation function</p> <pre><code>domain = Select[Tally[data[[All, 1]]], #[] == 1 &amp;][[All, 1]]; </code></pre> <p>Create Interpolation functions and evaluate at 0 These are for the top and bottom halves of the fn</p> <pre><code>Interpolation[Select[data, #[] &lt; 0 &amp;&amp; MemberQ[domain, #[]] &amp;]] Interpolation[Select[data, #[] &gt; 0 &amp;&amp; MemberQ[domain, #[]] &amp;]] -2.99994 2.99994 </code></pre> <p>Max and Min on the domain can approximate the x intercepts:</p> <pre><code>Max[domain] Min[domain] 1.99985 -1.99985 </code></pre> <h2>EDIT</h2> <p>Assuming your ellipse isn't 0-centered you will need exact x-intercepts</p> <p>This requires a second domain and second set of interpolating functions, necessitating a transposition and reevaluation.</p> <pre><code>data2 = Reverse /@ data; domain2 = Select[Tally[data2[[All, 1]]], #[] == 1 &amp;][[All, 1]]; Interpolation[Select[data2, #[] &lt; 0 &amp;&amp; MemberQ[domain2, #[]] &amp;]] Interpolation[Select[data2, #[] &gt; 0 &amp;&amp; MemberQ[domain2, #[]] &amp;]] -1.99996 1.99996 </code></pre>