2 added 1 character in body
source | link

This could also be an example for InfinitLine. If your line is a vertical line the intersection is just the function value, i.e.{x,f[x]}. Given p1 = {1, 1}; p2 = {2, 3}; and

f[x_] := Sqrt[4 - x^2]

one can define

line = InfiniteLine[p1, p2]

and calculate the intersection points via

sols = NSolve[{x, y} \[Element] line \[And] {x, f[x]} \[Element] line]

I used SolveNSolve for greater flexibility. Putting the parts together you can define a function:

showPlot[p1_, p2_, f_, {xmin_, xmax_}] :=  Module[{line = InfiniteLine[{p1, p2}], sols, pts},  sols = NSolve[{x, y} \[Element] line \[And] {x, f[x]} \[Element]  line];  If[p1[[1]] == p2[[1]], pts = {p1[[1]], f[p1[[1]]]},    pts = {x, y} /. sols];  Show[{Plot[f[x], {x, xmin, xmax}], Graphics@line,     Graphics[{PointSize[Medium], Red, Point[pts]}]}]  ]

and use it directly:

showPlot[p1, p2, f, {-2, 2}]

enter image description here

Or wrap a Manipulate around:

g[x_] := x^3 - 2 x^2 + 3 x + 2

Manipulate[ showPlot[p1, p2, g, {-2, 2}], {{p1, {1, 1}}, Locator}, {{p2, {2, 1}},   Locator}]

enter image description here

This could also be an example for InfinitLine. If your line is a vertical line the intersection is just the function value, i.e.{x,f[x]}. Given p1 = {1, 1}; p2 = {2, 3}; and

f[x_] := Sqrt[4 - x^2]

one can define

line = InfiniteLine[p1, p2]

and calculate the intersection points via

sols = NSolve[{x, y} \[Element] line \[And] {x, f[x]} \[Element] line]

I used Solve for greater flexibility. Putting the parts together you can define a function:

showPlot[p1_, p2_, f_, {xmin_, xmax_}] :=  Module[{line = InfiniteLine[{p1, p2}], sols, pts},  sols = NSolve[{x, y} \[Element] line \[And] {x, f[x]} \[Element]  line];  If[p1[[1]] == p2[[1]], pts = {p1[[1]], f[p1[[1]]]},    pts = {x, y} /. sols];  Show[{Plot[f[x], {x, xmin, xmax}], Graphics@line,     Graphics[{PointSize[Medium], Red, Point[pts]}]}]  ]

and use it directly:

showPlot[p1, p2, f, {-2, 2}]

enter image description here

Or wrap a Manipulate around:

g[x_] := x^3 - 2 x^2 + 3 x + 2

Manipulate[ showPlot[p1, p2, g, {-2, 2}], {{p1, {1, 1}}, Locator}, {{p2, {2, 1}},   Locator}]

enter image description here

This could also be an example for InfinitLine. If your line is a vertical line the intersection is just the function value, i.e.{x,f[x]}. Given p1 = {1, 1}; p2 = {2, 3}; and

f[x_] := Sqrt[4 - x^2]

one can define

line = InfiniteLine[p1, p2]

and calculate the intersection points via

sols = NSolve[{x, y} \[Element] line \[And] {x, f[x]} \[Element] line]

I used NSolve for greater flexibility. Putting the parts together you can define a function:

showPlot[p1_, p2_, f_, {xmin_, xmax_}] :=  Module[{line = InfiniteLine[{p1, p2}], sols, pts},  sols = NSolve[{x, y} \[Element] line \[And] {x, f[x]} \[Element]  line];  If[p1[[1]] == p2[[1]], pts = {p1[[1]], f[p1[[1]]]},    pts = {x, y} /. sols];  Show[{Plot[f[x], {x, xmin, xmax}], Graphics@line,     Graphics[{PointSize[Medium], Red, Point[pts]}]}]  ]

and use it directly:

showPlot[p1, p2, f, {-2, 2}]

enter image description here

Or wrap a Manipulate around:

g[x_] := x^3 - 2 x^2 + 3 x + 2

Manipulate[ showPlot[p1, p2, g, {-2, 2}], {{p1, {1, 1}}, Locator}, {{p2, {2, 1}},   Locator}]

enter image description here

1
source | link

This could also be an example for InfinitLine. If your line is a vertical line the intersection is just the function value, i.e.{x,f[x]}. Given p1 = {1, 1}; p2 = {2, 3}; and

f[x_] := Sqrt[4 - x^2]

one can define

line = InfiniteLine[p1, p2]

and calculate the intersection points via

sols = NSolve[{x, y} \[Element] line \[And] {x, f[x]} \[Element] line]

I used Solve for greater flexibility. Putting the parts together you can define a function:

showPlot[p1_, p2_, f_, {xmin_, xmax_}] :=  Module[{line = InfiniteLine[{p1, p2}], sols, pts},  sols = NSolve[{x, y} \[Element] line \[And] {x, f[x]} \[Element]  line];  If[p1[[1]] == p2[[1]], pts = {p1[[1]], f[p1[[1]]]},    pts = {x, y} /. sols];  Show[{Plot[f[x], {x, xmin, xmax}], Graphics@line,     Graphics[{PointSize[Medium], Red, Point[pts]}]}]  ]

and use it directly:

showPlot[p1, p2, f, {-2, 2}]

enter image description here

Or wrap a Manipulate around:

g[x_] := x^3 - 2 x^2 + 3 x + 2

Manipulate[ showPlot[p1, p2, g, {-2, 2}], {{p1, {1, 1}}, Locator}, {{p2, {2, 1}},   Locator}]

enter image description here