1
$\begingroup$

I'm trying to minimize this type of quadratic form:

expr = (-0.1 x1 + x2 + 1.2 x3 + x4 - x5)^2 + (x1 + 1.2 x2 + x3 - x4 - 
    0.1 x5)^2 + (1.2 x1 + x2 - x3 - 0.1 x4 + x5)^2 + (-x1 - 0.1 x2 + 
    x3 + 1.2 x4 + x5)^2 + (x1 - x2 - 0.1 x3 + x4 + 1.2 x5)^2

where x1,...,x5 are integers not simulteneously zero. Then I performed

Minimize[expr, 
 x1^2 + x2^2 + x3^2 + x4^2 + x5^2 != 0, {x1, x2, x3, x4, 
  x5}, Integers]

which apparently yields a solution {4.45, {x1 -> 0, x2 -> 0, x3 -> 0, x4 -> -1, x5 -> 0}}, but with the warning 'NMinimize::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations.'

Does this mean that the solution is not actually a solution? What is the meaning behind the warning? I can only find information related to 'NMinimize' (in which I believe 'Minimize' is based).

$\endgroup$
1
  • $\begingroup$ expr = (-0.1 x1 + x2 + 1.2 x3 + x4 - x5)^2 + (x1 + 1.2 x2 + x3 - x4 - 0.1 x5)^2 + (1.2 x1 + x2 - x3 - 0.1 x4 + x5)^2 + (-x1 - 0.1 x2 + x3 + 1.2 x4 + x5)^2 + (x1 - x2 - 0.1 x3 + x4 + 1.2 x5)^2; Minimize[{expr, {x1, x2, x3, x3, x5} != {0, 0, 0, 0, 0}}, {x1, x2, x3, x4, x5} ∈ Integers, Method -> "DifferentialEvolution"] $\endgroup$
    – cvgmt
    Commented Oct 2, 2021 at 2:11

1 Answer 1

2
$\begingroup$

Use arbitrary precision rather than machine precision

Clear["Global`*"]

$Version

(* "12.3.1 for Mac OS X x86 (64-bit) (June 19, 2021)" *)

expr = (-0.1 x1 + x2 + 1.2 x3 + x4 - x5)^2 + (x1 + 1.2 x2 + x3 - x4 - 
       0.1 x5)^2 + (1.2 x1 + x2 - x3 - 0.1 x4 + x5)^2 + (-x1 - 0.1 x2 + x3 + 
       1.2 x4 + x5)^2 + (x1 - x2 - 0.1 x3 + x4 + 1.2 x5)^2 // 
   SetPrecision[#, 10] &;

Minimize[{expr, x1^2 + x2^2 + x3^2 + x4^2 + x5^2 != 0}, {x1, x2, x3, x4, 
  x5}, Integers]

(* {4.450000000, {x1 -> 0, x2 -> 0, x3 -> 0, x4 -> 0, x5 -> 1}} *)
$\endgroup$
2
  • $\begingroup$ Thank you. Alternatively, can I do something like Minimize[{SetPrecision[expr,9], x1^2 + x2^2 + x3^2 + x4^2 + x5^2 != 0}, {x1, x2, x3, x4, x5}, Integers] instead? It seems to work better when I minimize similar quadratic forms but with more variables. Or does this interfere with the solution somehow? $\endgroup$ Commented Oct 2, 2021 at 1:36
  • $\begingroup$ For this problem, it doesn't matter whether you set the precision separately or as part of the definition of expr as long as Minimize is not working with machine precision. $\endgroup$
    – Bob Hanlon
    Commented Oct 2, 2021 at 1:46

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.