# intersection between two curves in Mathematica [duplicate]

I have a ListLinePlot of some datas and a plot of a constant function. How can I find the intersection point?

My data are:

data = {{0.2*10^4, 0.57}, {0.6*10^3, 0.56}, {0.2*10^3, 0.55}, {0.6*10^2, 0.53},
{0.2*10^2, 0.49}, {6, 0.44}, {2, 0.38}, {0.6, 0.33}, {0.2, 0.23}};


and I would like to find the intersection with y = 0.29.

• Let's see a concrete example?
– Öskå
Jul 16, 2014 at 10:28
• I have these datas:
– Ema
Jul 16, 2014 at 10:31
• {{0.2*10^4, 0.57}, {0.6*10^3, 0.56}, {0.2*10^3, 0.55}, {0.6*10^2, 0.53}, {0.2*10^2, 0.49}, {6, 0.44}, {2, 0.38}, {0.6, 0.33}, {0.2, 0.23}} and i vahe done the ListLinePlot. But i have yo intersecate this plot with y=0.29. How can i find the solution?
– Ema
Jul 16, 2014 at 10:33
• NSolve[(0.29 - 0.23)/(x - 0.2) == (0.33 - 0.23)/(0.6 - 0.2), x] Jul 16, 2014 at 10:44

Using this function:

data = {{0.2*10^4, 0.57}, {0.6*10^3, 0.56}, {0.2*10^3, 0.55}, {0.6*10^2, 0.53},
{0.2*10^2, 0.49}, {6, 0.44}, {2, 0.38}, {0.6, 0.33}, {0.2, 0.23}};
f = Interpolation[data, InterpolationOrder -> 1];
y[x_] := 0.29
x0 = First[x /. FindRoot[f[x] - y[x], {x, #[[1, 1]], #[[2, 1]]}] & /@
Select[Partition[Sort@Last@Last@Reap[Plot[f[x] - y[x], {x, 0.2, 2000},
EvaluationMonitor :> Sow[{x, f[x] - y[x]}]]], 2, 1], #[[2, 2]] #[[1, 2]] <= 0 &]];
Plot[{f[x], y[x]}, {x, 0.2, 10}, PlotRange -> Full, AxesOrigin -> {0, 0},
Epilog -> {Red, PointSize@.02, Point@{#, y@#} &@x0}]


So the coordinates of the point are:

{#, y@#} &@x0

{0.44, 0.29}


I might sound terribly pedantic here, but the answer is simply: Not at all.

The problem is that you have a finite set of data points, none of which has a y-value of 0.29. So there is no 'intersection' between a constant line and a number of points.

The other two answers above gave you a solution on how to find the intersection between the horizontal line and a suitably interpolated data set - in both cases linear interpolation has been assumed. That works, of course, but is the answer to your question only under very restricted circumstances (in case you wonder ListLinePlot has the option InterpolationOrder).

So if this is a real-world problem, you would have to specify what sort of function is used to either interpolate or fit your data set and then use FindRoot or 'NSolve' to obtain a numerical approximation.