the point p is on the graph f(x)=x^2+2x+5 determine the distance from the point (-3,-2) to the point P as a function of x

If the point (h,k) is closest to P, then the distance is

z = √((h+3)^2 + (k+2)^2) = √((h+3)^2 + (h^2+2h+8)^2)
dz/dh=0 at h = -1.1533
f(-1.1533) = 4.0235
so P = (-1.1533,4.0235)

check:
the slope of f(x) is 2x+2
f'(-1.1533) = -0.3066
so the slope of the normal is -3.2626
and the slope of the line from P to (-3,-2) is
(4.0235+2)/(-1.1533+3) = 3.2618

close enough for me.