2
$\begingroup$

FindMinimum has a very convenient feature:

If the starting point for a variable is given as a list, the values of the variable are taken to be lists with the same dimensions.

I do not find a similar feature for NMinimize. Is there a simple work around?

$\endgroup$

1 Answer 1

2
$\begingroup$

Just reading the documentation for NMinimize tells you that this feature is not present. Furthermore, NMinimize does not take "starting point for a variable", so that is necessarily so.

Now if what you want is to find the $\vec{x}$ that minimizes $f(\vec{x})$, for example for dimension 5, and using Norm as ans example function

f = Norm;
With[{xx = Array[x, 5]},
 NMinimize[f[xx], xx]
 ]

Or you could define something like this

NVectorMinimize[f_, x_, n_] := Block[
  {
   xx = Array[Unique[], n],
   fmin,
   vec,
   func = Function[x, f][xx]
   },
  {fmin, vec} = NMinimize[func, xx];
  {fmin, x -> (xx /. vec)}
  ]


NVectorMinimize[f[x], x, 4]
(* {1.9299*10^-11, x -> {-2.5935*10^-12, -1.0298*10^-11, -9.0777*10^-13, -1.6089*10^-11}} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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