
Mathematica problem
Hi all,
Anybody knows how to remove the complex values (not real number)of the function when using NMaximize command?
e.g. I have a function F(x), F(x) may be a complex number for some x. so how to remove these values in order to use the command NMaximize[F(x),x]?
Thanks a lot,
Cheers,
xdu

I wold just take the real part of it:
In[7]:= f[x_] := 1  x^2;
NMaximize[f[x], x]
g[x_] := 1  x^2 + 3 I x;
NMaximize[Re[g[x]], x]
Out[8]= {1., {x > 0.}}
Out[10]= {1., {x > 7.08002*10^9}}

Thank Shawsend,
But I donot think it is the right way to solve the problem because it also depends on the function.
I am wondering if it is possible to add a conditional restriction into the NMaximize function, e.g. If[f(x)∈complexes,Infinity,f(x)].