Hey marsalanuddin.

The first suggestion I have is to find a way of finding the intercept of the line with the x-axis and then use this to get your distance function.

We know that for a straight-line y = 0 so given y = mx + b this means that x = -b/m where m is the slope of the tangent.

Also minimizing d^2 will minimize d (i.e. the distance function).

So your line will be from (-b/m,0) to (x,y(x)) for some tangent line, so try finding a minimization problem given that x > 0