1
$\begingroup$

I'm trying to learn how to use the function Minimize in Mathematica.

I first defined the following function in Mathematica:

$$r(x,y,z,i)=\sqrt{(x-X_i)^2+(y-Y_i)^2+(z-Z_i)^2}$$

with the command

r[x_, y_, z_, i_] := Sqrt[(x-Subscript[X, i])^2 + (y-Subscript[Y, i])^2 + (z-Subscript[Z, i])^2]

Then I tried minimizing the following function over $x,y,z$:

$$ f(x,y,z)=(R_i-r(x,y,z,i))^2 $$

with the following command:

Minimize[(Subscript[R, i] - r[x, y, z, 1])^2, {x, y, z}]

The output I was expecting is a circle of points centered around $(X_i,Y_i,Z_i)$ and with radius $R_i$ (since at these points the function attains the value zero), or at least any point on that circle.

However, Mathematica outputs a very long and (for my knowledge level) cryptic solution. I can't think of any reasonable way to post the output here in a human-readable way, so perhaps it's easier if you try doing the commands in your Mathematica and see the output there (if someone thinks it's clearer, I can insert the whole output here, or perhaps a screenshot of it).

So my question is: am I doing something wrong, or is there a way to interpret this output in a meaningful way?

Any help would be appreciated, thank you.

$\endgroup$
  • $\begingroup$ You need to have assumptions for your X,Y,Z,R $\endgroup$ – Feyre Dec 6 '16 at 12:56
  • $\begingroup$ @Feyre, You mean like, assuming they're real/positive? $\endgroup$ – JLagana Dec 6 '16 at 12:57
  • $\begingroup$ @Feyre: I guess $R_i$ needs to be positive, no? $\endgroup$ – JLagana Dec 6 '16 at 13:00
  • $\begingroup$ Oh, yes. R has to be positive, the others merely real. $\endgroup$ – Feyre Dec 6 '16 at 13:00
  • $\begingroup$ @Feyre: I tried simplifying the result with some assumptions but I get the same output. The command I tried was: Simplify[Minimize[(Subscript[R, i]-r[x,y,z,1])^2,{x,y,z}],{Subscript[R, i]>0,Element[{x,y,z,Subscript[X, i],Subscript[Y, i],Subscript[Z, i]},Reals]}] $\endgroup$ – JLagana Dec 6 '16 at 13:03
2
$\begingroup$

There are two problems here:

  1. Your proposed solution is only valid if $R_i > 0$

  2. The minimum is attained in every point on a sphere. But Minimize returns only one point, not a set of points. The documentation says,

    Even if the same minimum is achieved at several points, only one is returned.

Simplify the result as Simplify[..., Subscript[R, i] > 0] and you get a clear minimum value: 0. The minimum point looks complicated, but it is valid: it is on the sphere.

If you only want the minimum value, use MinValue.

To get a simpler minimum point, you could provide some constraints which restrict the solution to a single point, e.g.

result = 
  Minimize[{(Subscript[R, i] - r[x, y, z, 1])^2, 
    x == Subscript[X, 1] && y == Subscript[Y, 1]}, {x, y, z}];

Simplify[result, Subscript[R, i] > 0]
(* {0, {x -> Subscript[X, 1], y -> Subscript[Y, 1], 
  z -> -Subscript[R, i] + Subscript[Z, 1]}} *)
$\endgroup$
  • $\begingroup$ Thank you for the clear explanation. I still fail to see how you can check if the minimum point is valid, perhaps you can elaborate a bit? $\endgroup$ – JLagana Dec 8 '16 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.