Re: Is this a problem in mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg74639] Re: Is this a problem in mathematica?
- From: "Dana DeLouis" <dana.del at gmail.com>
- Date: Thu, 29 Mar 2007 02:33:08 -0500 (EST)
> Minimize[minDist, y == 1 + x^2, {x, y}] > but x also has another answer: +1/Sqrt[2]. Here's an alternative using Derivatives. Plot[x^2 + 1, {x, -2, 2}, AspectRatio -> Automatic, GridLines -> Automatic]; pt = {0, 2}; {x, 1 + x^2} - pt {x, -1 + x^2} Distance Equation: I used Simplify to remove Abs[ ] d = Simplify[Norm[%], x >= 0] Sqrt[1 - x^2 + x^4] Take the Derivative... D[d, x] (-2*x + 4*x^3)/(2*Sqrt[1 - x^2 + x^4]) Solve[% == 0, x] {{x -> 0}, {x -> -(1/Sqrt[2])}, {x -> 1/Sqrt[2]}} There are 3 possible solutions. However, with x->0, the distance is not the shortest: d /. % {1, Sqrt[3]/2, Sqrt[3]/2} Therefore, the remaining 2 solutions would be the shortest. Ie.. {x -> -(1/Sqrt[2])}, {x -> 1/Sqrt[2]} -- HTH :>) Dana DeLouis Windows XP & Mathematica 5.2 "traz" <t_raz at yahoo.com> wrote in message news:eud3g1$l0t$1 at smc.vnet.net... > Let's say I wanna solve this problem: > > Determine point(s) on y = x^2 +1 that are > closest to (0,2). > > So in mathematica: > > minDist = (x - 0)^2 + (y - 2)^2; > Minimize[minDist, y == 1 + x^2, {x, y}] > > Output will give you: x -> -1/Sqrt[2], y -> 3/2 > > but x also has another answer: +1/Sqrt[2]. Is this a problem in mathematica or can my code be changed to output the other value of x for the minimum distance? >