0
$\begingroup$

Define the following vectors and matrices:

v1={2,0}
v2={0,1}
v3={2,1}
S={{2,0},{0,1}}
A={{2,0},{0.311,1}}

I need to find the maximum of $\displaystyle{\frac{|S(n_1v_1+n_2v_2)+A(n_3v_3)|}{|n_1v_1+n_2v_2+n_3v_3|}}$ for $n_1,n_2,n_3\in \mathbb{Z}$ with the condition $|n_1v_1+n_2v_2+n_3v_3|\neq 0$.

I thought the following code would do the job:

FindMaximum[{Norm[S.(n1*v1) + S.(n2*v2) + A.(n3*v3)]/
Norm[n1*v1 + n2*v2 + n3*v3], Norm[n1*v1 + n2*v2 + n3*v3] > 0, 
n1 \[Element] Integers,n2 \[Element] Integers,n3 \[Element] Integers}, {n1, n2, n3}]

But, instead of the solution, I get in output the following error:

Constraints in \ {n1[Element]Integers,Sqrt[Abs[n2+n3]^2+Abs[Times[<<2>>]+Times[<<2>>]]\ ^2]>0} are not all equality or inequality constraints. With the \ exception of integer domain constraints for linear programming, \ domain constraints or constraints with Unequal (!=) are not \ supported. >>

What am I doing wrong and how can I fix it?

Thank you

$\endgroup$
7
  • 1
    $\begingroup$ You entered a nonlinear integer optimization problem. Such problems can be quite hard and there are few numerical methods that can solve such problems. The error message tells you that FindMaximum can only handle linear optimization problems over integer numbers and nonlinear optimization problems over real numbers. $\endgroup$ Jul 17, 2017 at 17:39
  • $\begingroup$ @Bill I fixed it, but the error message is the same $\endgroup$
    – User28341
    Jul 17, 2017 at 17:48
  • 1
    $\begingroup$ Based on a little experimentation it looks like you might find your maximum by choosing a large positive integer value b and then n1= -b; n2=n1+1; n3=b; and you get your maximum. The bigger the b the bigger the maximum, to infinity and beyond. Please test that claim carefully before you depend on it. $\endgroup$
    – Bill
    Jul 17, 2017 at 18:10
  • 1
    $\begingroup$ The help pages show FindMaximum uses methods that can find a local maximum. The help pages show Maximize uses very different methods that can find a global maximum given certain conditions. With my conditions on n1,n2,n3 it instantly reports there is no maximum. I found my claim with a little Monte Carlo searching followed by brute force larger and larger nested For loops to confirm my conjecture. Then @Carl Woll showed what I had hoped you might discover for yourself. If you remove the integer condition then you might Plot your expression to see what it does. $\endgroup$
    – Bill
    Jul 17, 2017 at 20:07
  • 1
    $\begingroup$ best= -Infinity; Do[{n1,n2,n3}=RandomInteger[{-100,100},3]; If[Norm[n1*v1+n2*v2+ n3*v3]>0,zed = Norm[S.(n1*v1)+S.(n2*v2)+A.(n3*v3)]/Norm[n1*v1+n2*v2+n3*v3]; If[best<zed, best=zed; Print[{N[best],n1,n2,n3}]]] , {10^6}] and best= -Infinity; For[n1= -100,n1<=100,n1++,For[n2= -100,n2<=100,n2++, For[n3= -100,n3<=100,n3++, If[Norm[n1*v1+n2*v2+n3*v3]>0, zed = Norm[S.(n1*v1)+S.(n2*v2)+A.(n3*v3)]/Norm[n1*v1+ n2*v2+n3*v3]; If[best<zed,best=zed; Print[{N[best],n1,n2,n3}]]]]]] $\endgroup$
    – Bill
    Jul 17, 2017 at 21:44

1 Answer 1

2
$\begingroup$

Expanding on @Bill's comment. The maximum is $\infty$. Consider:

Norm[S.(n1*v1)+S.(n2*v2)+A.(n3*v3)]/Norm[n1*v1+n2*v2+n3*v3] /. {n1->-n3,n2->-n3-1}

Abs[-1 + 0.622 n3]

The expression grows without bound as $n3 \to \infty$

$\endgroup$
1
  • $\begingroup$ Thank you for your answer. Without the conditions of $n_i$ being integers Mathematica returned the result 2.00337 with a warning message ("The algorithm does not converge to the tolerance of \ 4.806217383937354`*^-6 in 500 iterations..."). How is that it didn't state that the function is unbounded? $\endgroup$
    – User28341
    Jul 17, 2017 at 19:23

Your Answer

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

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