Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

minimize with complex numbers

494 views
Skip to first unread message

shama shahbaz

unread,
Aug 11, 2008, 6:08:25 AM8/11/08
to
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 methamatica it becomes

Minimize[{( x[1]+x[2])2
+((1+1i)x[1]+(1-1 i)x[2])2},{x[1],x[2]}]


i want my answer to be in complex number come somebody tell me where i am wrong

thanx

Jean-Marc Gulliet

unread,
Aug 12, 2008, 4:45:13 AM8/12/08
to
shama shahbaz wrote:

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

Bill Rowe

unread,
Aug 12, 2008, 4:45:46 AM8/12/08
to
On 8/11/08 at 6:08 AM, shamma...@yahoo.com (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 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.

Jens-Peer Kuska

unread,
Aug 12, 2008, 4:47:23 AM8/12/08
to
Hi,

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

Torsten Hennig

unread,
Aug 13, 2008, 9:35:00 AM8/13/08
to
> 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
> r 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 methamatica it becomes

>
> Minimize[{( x[1]+x[2])2
> +((1+1i)x[1]+(1-1 i)x[2])2},{x[1],x[2]}]
>
>
> i want my answer to be in complex number come
> somebody tell me where i am wrong
>
> thanx
>

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.

Benjamin Hell

unread,
Aug 13, 2008, 9:35:11 AM8/13/08
to
Well, minimize doesn't work with complex arguments. And that is in no way a restriction, because seen from a mathematical standpoint searching for a minimum in a complex set doesn't make any sense without further specification. I could go into detail about that, but this may be confusing for you, so let me just mention the main idea:
To explain what is a minimum you need to have a smaller than ("<") relation. So one has to define that for a set of complex numbers. Consider the following example of two complex numbers z1=1+2i and z2=2+0.5i. Which one would you say is greater than the other one? Hard to say that here, right? So what usually appears in applications (and that's something you might want to take in account) is that you compare complex numbers by their absolute value respectively their norm. Usually one takes the euclidean norm |.|, which is defined by |z|=sqrt(a^2+b^2) where z=a+ib. So the norm delivers a real number (a norm always does) and your are in your first case of comparing real numbers. Hope this helps understanding the problem.

shama shahbaz

unread,
Aug 13, 2008, 9:36:25 AM8/13/08
to
hi
i have transformed my complex valued problem into real value problem as below but still when i try to MInimize it i didnt get a solution
(a1+b1i)x[1] +(a2+b2i) x[2]=0
(c1+d1i)x[1] +(c2+d2i) x[2]=0


a1 u1 - b1 v1 + a2 u2 - b2 v2 = 0
c1 u1 - d1 v1 + c2 u2 - d2 v2 = 0
a1 v1 + b1 u1 + a2 v2 + b2 u2 = 0
c1 v1 + d1 u1 + c2 v2 + d2 u2 = 0,



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 .
Regards

Bill Rowe

unread,
Aug 14, 2008, 7:00:46 AM8/14/08
to
On 8/13/08 at 4:40 AM, shamma...@yahoo.com (shama shahbaz) wrote:

>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.

Jean-Marc Gulliet

unread,
Aug 14, 2008, 7:01:07 AM8/14/08
to
shama shahbaz wrote:

<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

0 new messages