# To find the point of Intersection of two line in Mathematica

How to find the intersection point of two lines exactly, the lines are generated using some data. The x-axis is on the logarithmic scale and the y-axis is on a linear scale.

 a={9.42174,9.38369,9.34981,9.31951,9.2923,9.26774,9.24551,9.22529,9.20684,9.18995,9.17444,9.16014,9.14693,9.13469,9.12331,9.11272,9.10283,9.09358,9.08491,9.07676,9.06909,9.06186,9.05504,9.04858,9.04247,9.03666,9.03115,9.02591,9.02091,9.01615,9.0116,9.00726,9.0031,8.99911,8.9953,8.99163,8.98811,8.98473,8.96863,8.96107,8.9542,8.94792,8.94215,8.93682,8.9319,8.92732,8.92305,8.91905,8.9153,8.91177,8.90845,8.9053,8.90232,8.89948,8.89678,8.89421,8.89175,8.88939,8.88713,8.88495,8.88286,8.88084,8.87889,8.87701,8.87518,8.87341,8.87169,8.87002,8.86839,8.8668,8.86526,8.86374,8.86226,8.86081,8.85938,8.85799,8.77674,7.80832,6.71405,5.97698,5.4407,5.02867,4.69958,4.42901,4.20153,4.00685,3.83783,3.6893,3.55746,3.43942,3.33294,3.23626,3.14798,3.06695,2.99224,2.92307,2.85879,2.79886,2.74281,2.69024,2.64081,2.59421,2.5502,2.50854,2.46902,2.43148,2.39575,2.3617,2.32919,2.29811,2.26836,2.23986,2.2125};
b={10.8371,10.833,10.8289,10.8248,10.8207,10.8166,10.8125,10.8083,10.8042,10.8,10.7958,10.7916,10.7874,10.7831,10.7789,10.7746,10.7703,10.7659,10.7616,10.7572,10.7527,10.7483,10.7438,10.7393,10.7348,10.7302,10.7256,10.7209,10.7162,10.7115,10.7067,10.7019,10.697,10.6921,10.6871,10.6821,10.6771,10.6719,10.6436,10.6274,10.6107,10.5932,10.5751,10.5562,10.5365,10.5159,10.4944,10.4718,10.4481,10.4233,10.3972,10.3698,10.341,10.3107,10.2789,10.2456,10.2106,10.1739,10.1356,10.0956,10.054,10.0107,9.96584,9.91947,9.87167,9.82256,9.77224,9.72084,9.66849,9.61532,9.56147,9.50708,9.45226,9.39715,9.34186,9.2865,7.11554,5.73358,4.95373,4.44107,4.07219,3.7908,3.56718,3.384,3.2304,3.09919,2.98539,2.88544,2.79671,2.71724,2.64548,2.58025,2.52058,2.46572,2.41502,2.36797,2.32413,2.28315,2.2447,2.20854,2.17442,2.14215,2.11156,2.0825,2.05484,2.02847,2.00327,1.97917,1.95606,1.93389,1.91259,1.8921,1.87236};
sd1 = Subdivide[0.001, 0.5, 300];
sd2 = Subdivide[0.55, 2, 300];
sd3 = Subdivide[2.2, 100, 300];
sd = Flatten[{sd1, sd2, sd3}];
sd = sd[[1 ;; All ;; 8]];
data1 = Transpose[{sd, a}];
data2 = Transpose[{sd, b}];
ListLogLinearPlot[{data1, data2}, Joined -> True, PlotRange -> All]


Here I show a tricky direct solution using GraphicsMeshFindIntersections which doesn't need interpolation:

pic=ListLogLinearPlot[{data1, data2}, Joined -> True, PlotRange -> All];
p=GraphicsMeshFindIntersections[pic[[All, 2]]  ]
(*{{0.841204, 8.84133}}*)


Show[{pic, Graphics[{Red, PointSize[.025], , Point[p]}]}]


The x value of the intersection evaluates to

Exp[p[[1]]]
(*2.31916*)

• @Ulrich Neumann It is not working form me, I am using mathematica v11.3. and the result of the previous solution and the solutions you got are different – acoustics Oct 18 '19 at 3:19
• @acoustics I don't know your previous result, but the intersectionpoint seems to be ok (see my modified answer). Keep in mind the different coordinates! – Ulrich Neumann Oct 18 '19 at 6:36
• I also got the same result but which one I have to consider 2.31916 or 0.841204. – acoustics Oct 18 '19 at 6:57
• Probably the last one, if you want the result in the coordinate-system of data1, data2 – Ulrich Neumann Oct 18 '19 at 7:00
• Take 2.31916 or alternatively use pic=ListLinePlot[...] in my answer – Ulrich Neumann Oct 18 '19 at 7:11

I would generate an InterpolatingFunction for each dataset and then find the intersection with FindRoot:

FindRoot[Interpolation[data1][x] - Interpolation[data2][x], {x, 1}]


FindRoot will look for the root of the given function closest to the provided starting point (in this case: 1).

• Is it Log value or the normal value, I got an answer which is around 2.304, I am get little confused what value is it. – acoustics Oct 17 '19 at 11:27
• The way you plot the data (in this case on a logarithmic chart) does not affect the data itself. So it's the normal value. – banone Oct 17 '19 at 11:30