title: Fastest way to find minimum distance of one point to points on a curve
body: <p>I'm looking for a fast solution for the following problem:</p>
  
  <p><img src="https://i.imgur.com/gpDooU6.png" alt="illustration of minimum distance problem"></p>
  
  <p>I have a fixed point (let's say the upper right on the white measurement line) and need to find the closest point on a curve made of equally spaced points (the lower curve). Additionally, I do this for every point on the upper curve to draw the distances between the curves with different colours (three levels: below minimum [red], between minimum and maximum [orange] and above maximum [green]).</p>
  
  <p>My current solution is a tradeoff: I take the fixed point, iterate through an arbitrary interval (e. g. 50 units to the left and right of the fixed point) and calculate the distance of each pair. This saves some CPU power, but it is neither elegant nor accurate, since I could miss a minimum distance outside my chosen interval. </p>
  
  <p>Any proposals for a faster algorithm?</p>
  
  <p>Edit: Equally spaced means all points have the same distance on the x-axis, this is true for both curves. Also I do not need to interpolate between the points, this would be too time consuming.</p>