Distance between point and sine wave

Let your point be $(e,f)$ so we don't reuse $x,y$. An approximate approach is as follows: First, find the limits of the half wave of interest. Let's say we are above the curve. You want the local minimum nearest $e$ and the local maximum on the other side of $e$. The perpendicular at a point has slope that is the inverse reciprocal of the derivative. The perpendicular from the maximum will be vertical and on one side of $(e,f)$, the perpendicular from the minimum will be on the other side of $(e,f)$ Call up your favorite one-dimensional root finder to find the $x$ value where the perpendicular goes through $(e,f)$. We have bracketed the root, so it should be easy to find. Now find the distance from $(x,y)$ to $(e,f)$

Tags:

Optimization