Closest Point on a 3D Quadratic Surface

Hi All, first post, hope I'm obeying all the rules :)

If I have a 3d quadratic surface defined by and a point in space defined by the position vector , how can I determine the closest point on the surface to p?

I suspect the solution lies down the path of minimising the value of the difference between the points, or finding the values of x, y and z that minimise , but my maths is rusty and I have a feeling that if this is possible it would involve implicit differentiation or one of the other techniques I never quite mastered the first time around.

Any help or even a pointer to a different (easier) approach would be much appreciated.

Thanks,

Dave.