In one of my homework questions I am tasked with finding the shortest distance between a point $P = (4, 18, 9)$ and a vector curve $r(t) = (t^2, 2t, 2t)$. I believe the correct way to solving the problem is to find the values of t for which the distance between the point in line is the lowest; that is, I need to find t such that $D'(t) = 0$. But whenever I try to do this I get a ridiculous quadratic equation, which makes me think I'm plugging values into $D(t)$ improperly.
$$D(t)^2 = (t^2 -4)^2 + (2t-18)^2 + (2t-9)^2$$
Is this the correct formula for the distance between P and an arbitrary point on $r(t)$? Am I misunderstanding the distance formula, or do I have to do something with r(t) before putting its components in the equation?