Here's a very useful hint. The distance formula has a square root in it, as you know, and thus is frustrating to differentiate. However take note of the fact that if you minimize , you also minimize D. So try that out and if you're still stuck show your work and we'll find your error.