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
FindMaximum
can only handle linear optimization problems over integer numbers and nonlinear optimization problems over real numbers. $\endgroup$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$FindMaximum
uses methods that can find a local maximum. The help pages showMaximize
uses very different methods that can find a global maximum given certain conditions. With my conditions onn1,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 mightPlot
your expression to see what it does. $\endgroup$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}]
andbest= -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$