Minimize requires that all functions present in the input be
real-valued. (It does not work with complex coefficient either.)
Note that the code you posted does not contain the imaginary unit, which
is denoted in Mathematica by I (capital i). You must have some other
error(s) since, having used the correct symbol for the imaginary unit, I
did not get the same message as yours.
In[1]:= expr = ((1 + 1 i)*x[1] + (1 - 1 i)*x[2])^2 + (x[1] + x[2])^2
Minimize[expr, {x[1], x[2]}]
Out[1]= (x[1] + x[2])^2 + ((1 + i) x[1] + (1 - i) x[2])^2
Out[2]= {0, {x[1] -> Piecewise[{{-1, i == 0}}],
x[2] -> Piecewise[{{0, i > 0 || i < 0}}, 1]}}
In[3]:= expr = ((1 + 1 I)*x[1] + (1 - 1 I)*x[2])^2 + (x[1] + x[2])^2
Minimize[expr, {x[1], x[2]}]
Out[3]= (x[1] + x[2])^2 + ((1 + I) x[1] + (1 - I) x[2])^2
During evaluation of In[3]:= Minimize::objc: The objective function \
(x[1]+x[2])^2+((1+I) x[1]+(1-I) x[2])^2 contains a nonreal constant \
1+I. >>
Out[4]= Minimize[(x[1] +
x[2])^2 + ((1 + I) x[1] + (1 - I) x[2])^2, {x[1], x[2]}]
Regards,
-- Jean-Marc
>hi , when i use minimize command with real numbers i get the
>required answer but with complex number it doesnt give me any answer or er=
ror
>Syntax::sntxb : Expression cannot begin with "(1+1 i) ` x[1]+(1-1 i)
>` x[2]". Syntax::tsntxi : "(1+1 i) ` x[1]" is incomplete; more input
>is needed. Syntax::sntxi : Incomplete expression; more input is
>needed.
>My minimize expression is
>((1+1i)*x[1] +(1-1i)*x[2] )^2 +(x[1]+x[2])^2
You have syntax issues here. In Mathematica, x[2] is the
function x to be evaluated at 2. I doubt this is what you had in
mind. Also, the symbol i is not defined. You want the built-in
symbol I which is the square root of minus 1.
However, fixing the syntax issues will not get you what you
want. Minimize only works with real valued expressions. If I fix
your syntax problems by substituting x for x[1], y for x[2] and
I for i then Expand, I get
In[5]:= ((1 + I)*x + (1 - I)*y)^2 + (x + y)^2 // Expand
Out[5]= (1 + 2 I) x^2 + 6 y x + (1 - 2 I) y^2
which is clearly only real valued for the case where x^2 == y^2.
Minimize is restricted to real valued functions since for
complex variables x, y x > y is not defined.
a complex function map the complex plane into the complex
plane. Can you explain what a "Minimum" is for a maping
of a plane into a plane ??
Regards
Jens
shama shahbaz wrote:
> hi ,
> when i use minimize command with real numbers i get the required answer but
> with complex number it doesnt give me any answer or error
>
> Syntax::sntxb : Expression cannot begin with "(1+1 i) ` x[1]+(1-1 i) ` x[2]".
> Syntax::tsntxi : "(1+1 i) ` x[1]" is incomplete; more input is needed.
> Syntax::sntxi : Incomplete expression; more input is needed.
>
>
> My minimize expression is
>
> ((1+1i)*x[1] +(1-1i)*x[2] )^2 +(x[1]+x[2])^2
>
> in Mathematica it becomes
The complex number field can not be ordered ;
so minimization of a complex expression does not
make sense.
Maybe you want to minimize the norm of a complex
expression ?
Best wishes
Torsten.
>i have transformed my complex valued problem into real value problem as be=
low but still when i try to MInimize it i didnt get a solution
>(a1+b1i)x[1] +(a2+b2i) x[2]=0
You almost certainly have a syntax issue here. That is not to
say this isn't a valid Mathematica expression. Rather it almost
certainly isn't what you think.
This expression in Mathematica will evaluate as follows:
add a1 to b1i
multiply this result by the *function* x evaluated at 1
add a2 to b2i
multiply this result by the *function* x evaluated at 2
add the two products found above
then *set* the entire thing to 0
In essence, minimizing this expression is equivalent to
minimizing the constant 0 which clearly makes no sense.
First, what is it you are trying to represent as x[1]? Is this
supposed to be a subscripted variable?
If so, that is possible to do in Mathematica but not
particularly convenient. You can create subscripted variables
that behave like unsubscripted variables using the Notation
package. Failure to use that package will almost certainly give
results you don't expect at some point.
So, the first thing to get out of the problems you have is
simply not to use subscripted variables until you become more
expert with Mathematica.
Next, if you intended for the expression to be an *equation* you
need to be aware a single "=" is an assignment operator in
Mathematica. Equations are expressed using a double "=", e.g.
x + y == 0
would be an equation in Mathematica.
But for a minimization problem, it really doesn't make sense to
minimize an equation.
>Minimize[{(0.83 u1+0.4 u2-0.25 u3+3 u4+0.16 v1+0.6 v2+1.25 v3-2 v4)2+(2 u1=
-0.16 u2-0.6 u3-1.25 u4+3 v1+0.83 v2+0.4 v3-0.25 v4)2+(0.4 u1-0.25 u2+3 u3+=
0.83 u4+0.6 v1+1.25 v2-2 v3+0.16 v4)2+(-1.25 u1+2 u2-0.16 u3-0.6 u4-0.25 v1=
+3 v2+0.83 v3+0.4 v4)2+(-0.25 u1+3 u2+0.83 u3+0.4 u4+1.25 v1-2 v2+0.16 v3+0=
.6 v4)2+(-0.6 u1-1.25 u2+2 u3-0.16 u4+0.4 v1-0.25 v2+3 v3+0.83 v4)2+(3 u1+0=
.83 u2+0.4 u3-0.25 u4-2 v1+0.16 v2+0.6 v3+1.25 v4)2+(-0.16 u1-0.6 u2-1.25 u=
3+2 u4+0.83 v1+0.4 v2-0.25 v3+3 v4)2},{u1>0,v1>0,u2>0,v2>0,u3>0,v3>0,u4>0,v=
4>0},{u1,v1,u2,v2,u3,v3,u4,v4}]
>The error is
>Minimize::vdom : Variable domain {u1,v1,u2,v2,u3,v3,u4,v4}
>should be either Reals or Integers. i didnt understand it can
>anybody tell me what should i do .
The first thing you should do when you get an error message you
don't understand is read the online documentation for the
function you are trying to use. In particular for Minimize you
will find it expects at most three arguments
an expression to minimize
a list of variables
a domain for those variable
You provided
an expression to minimize
a list of inequalities
a list of variables
Mathematica saw the third argument wasn't a valid domain and
generated the error message you saw
If you look at the examples in the online documentation you will
see the constraints on the variables are to be included in a
single list with the expression to be minimized. That is:
Minimize[{x - 2 y, x^2 + y^2 <= 1}, {x, y}]
will minimize x 2 y subject to the constraint x^2 + y^2 <=1
But
Minimize[{x - 2 y}, {x^2 + y^2 <= 1}, {x, y}]
will generate the same kind of error message you saw.
However, when I correct your syntax to be what Minimize expects,
I get the result that the expression is 0 when all of the
variables are 0. Since that almost certainly isn't a useful
result, I strongly suspect you have other problems that are not
apparent from your post.
<snip>
> Minimize[{(0.83 u1+0.4 u2-0.25 u3+3 u4+0.16 v1+0.6 v2+1.25 v3-2 v4)2+(2 u1-0.16 u2-0.6 u3-1.25 u4+3 v1+0.83 v2+0.4 v3-0.25 v4)2+(0.4 u1-0.25 u2+3 u3+0.83 u4+0.6 v1+1.25 v2-2 v3+0.16 v4)2+(-1.25 u1+2 u2-0.16 u3-0.6 u4-0.25 v1+3 v2+0.83 v3+0.4 v4)2+(-0.25 u1+3 u2+0.83 u3+0.4 u4+1.25 v1-2 v2+0.16 v3+0.6 v4)2+(-0.6 u1-1.25 u2+2 u3-0.16 u4+0.4 v1-0.25 v2+3 v3+0.83 v4)2+(3 u1+0.83 u2+0.4 u3-0.25 u4-2 v1+0.16 v2+0.6 v3+1.25 v4)2+(-0.16 u1-0.6 u2-1.25 u3+2 u4+0.83 v1+0.4 v2-0.25 v3+3 v4)2},{u1>0,v1>0,u2>0,v2>0,u3>0,v3>0,u4>0,v4>0},{u1,v1,u2,v2,u3,v3,u4,v4}]
>
> The error is
> Minimize::vdom : Variable domain {u1,v1,u2,v2,u3,v3,u4,v4} should be either Reals or Integers.
> i didnt understand it can anybody tell me what should i do .
You have a spurious closing curly bracket at the end of the objective
function. Your expression should read,
Minimize[{(0.83 u1 + 0.4 u2 - 0.25 u3 + 3 u4 + 0.16 v1 + 0.6 v2 +
1.25 v3 - 2 v4)
2 + (2 u1 - 0.16 u2 - 0.6 u3 - 1.25 u4 + 3 v1 + 0.83 v2 +
0.4 v3 - 0.25 v4)
2 + (0.4 u1 - 0.25 u2 + 3 u3 + 0.83 u4 + 0.6 v1 + 1.25 v2 -
2 v3 + 0.16 v4)
2 + (-1.25 u1 + 2 u2 - 0.16 u3 - 0.6 u4 - 0.25 v1 + 3 v2 +
0.83 v3 + 0.4 v4)
2 + (-0.25 u1 + 3 u2 + 0.83 u3 + 0.4 u4 + 1.25 v1 - 2 v2 +
0.16 v3 + 0.6 v4)
2 + (-0.6 u1 - 1.25 u2 + 2 u3 - 0.16 u4 + 0.4 v1 - 0.25 v2 +
3 v3 + 0.83 v4)
2 + (3 u1 + 0.83 u2 + 0.4 u3 - 0.25 u4 - 2 v1 + 0.16 v2 +
0.6 v3 + 1.25 v4)
2 + (-0.16 u1 - 0.6 u2 - 1.25 u3 + 2 u4 + 0.83 v1 + 0.4 v2 -
0.25 v3 + 3 v4) 2, {u1 > 0, v1 > 0, u2 > 0, v2 > 0, u3 > 0,
v3 > 0, u4 > 0, v4 > 0}}, {u1, v1, u2, v2, u3, v3, u4, v4}]
Regards,
-- Jean-Marc