2
$\begingroup$

Below is my program. I don't know how to define the function f to make it work.

Another question:

When I define f as a vector of the form {x, x*y} and use

FindMinimum[Norm[f], {{x, 1}, {y, 1}}, Method -> "LevenbergMarquardt"]

it works. But is FindMinimum handling both problems the same way? I mean the norm and the sum? I ask because the solution that I get with Norm[f] is {x -> 3.95915*10^-9, y -> 1.}, which is not the local minimum obviously.

f[x_, y_] := {x, x*y}
FindMinimum[
  Sum[f[x, y][[i]]^2, {i, 1, 2}], {{x, 1}, {y, 1}}, 
  Method -> "LevenbergMarquardt"]

FindMinimum::notlm: The objective function for the method LevenbergMarquardt must be in a least-squares form: Sum[f[i][x]^2, {i, 1, n}] or Sum[w[i] f[i][x]^2, {i, 1, n}] with positive w[i].

$\endgroup$
2
  • $\begingroup$ Try Minimize[Norm[f[x, y]], {x, y}]? $\endgroup$
    – MarcoB
    Jul 3, 2018 at 19:51
  • $\begingroup$ @MarcoB I want to use the method "LevenbergMarquardt", and with this method, mathematica wants the function to minimize to be a sum of squares $\endgroup$
    – Salma
    Jul 3, 2018 at 22:58

1 Answer 1

3
$\begingroup$

As described here, sometimes it is difficult to write the minimand explicitly as a dot product that Mathematica will recognize. In that case, you can specify it explicitly:

FindMinimum[x^2 + x^2 y^2, {{x, 1}, {y, 1}},
  Method -> {"LevenbergMarquardt", "Residual" -> {x, x y}}
 ]
(* {1.10934*10^-31, {x -> 3.33067*10^-16, y -> 1.}} *)
$\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.