Hello!
Why don't the following commands produce equivalent results?
NMaximize[{10 *(-d[1] + d[2])^4* q[1, 2]^4 + (-d[1] + d[2])^2*
q[1, 2]^2* (4* q[1, 2]^2 + (q[1, 1] - q[2, 2])^2) -
6 *(d[1] - d[2])^3 *
q[1, 2]^2 (q[1, 1] - q[2, 2]) (d[1] *q[1, 1] + d[2]* q[2, 2]) +
2 *(d[1] - d[2])^4* q[1, 2]^2 *(d[1]* q[1, 1] + d[2]* q[2, 2])^2,
d[1]^2 + d[2]^2 == 1,
q[1, 1]^2 + 2*q[1, 2]^2 + q[2, 2]^2 == 1}, {q[1, 1], q[1, 2],
q[2, 2], d[1], d[2]}]
and
NMaximize[{10 *(-x + y)^4 *b^4 + (-x + y)^2*
b^2 *(4* b^2 + (a - c)^2) -
6 (x - y)^3* b^2 (a - c)* (x* a + y *c) +
2 *(x - y)^4 *b^2*(x *a + y *c)^2, x^2 + y^2 == 1,
a^2 + 2*b^2 + c^2 == 1}, {a, b, c, x, y}]
For the first I get output :
NMaximize::nosat: Obtained solution does not satisfy the following constraints within Tolerance -> 0.001`: {1-d[1]^2-d[2]^2==0,1-q[1,1]^2-2 q[1,2,2]^2==0}. >>
For the second I get (correct) output:
{12.0002, {a -> 1.01851*10^-6, b -> -0.707108, c -> -3.9843*10^-7,
x -> -0.707108, y -> 0.70711}}
The first comes from using a summation index inside a NMaximize routine and I get the wrong result. When I replace the indexed variables with a,b,c,x,y then I get the correct results. I want to be able to vary the limit of summation for such functions and optimize them but it is not computing correctly.
Thanks!