Results 1 to 3 of 3

Math Help - Mathematica problem

  1. #1
    xdu
    xdu is offline
    Newbie
    Joined
    Nov 2009
    Posts
    19

    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
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    Joined
    Aug 2008
    Posts
    903
    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}}
    Follow Math Help Forum on Facebook and Google+

  3. #3
    xdu
    xdu is offline
    Newbie
    Joined
    Nov 2009
    Posts
    19
    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)].
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Mathematica problem
    Posted in the Math Software Forum
    Replies: 0
    Last Post: October 14th 2010, 05:33 AM
  2. Mathematica, Calculus III Problem
    Posted in the Math Software Forum
    Replies: 0
    Last Post: March 16th 2010, 11:42 AM
  3. Mathematica Problem
    Posted in the Math Software Forum
    Replies: 8
    Last Post: March 16th 2010, 11:00 AM
  4. the problem in mathematica
    Posted in the Math Software Forum
    Replies: 2
    Last Post: November 6th 2009, 12:25 PM
  5. Mod and If Problem [Mathematica]
    Posted in the Math Software Forum
    Replies: 1
    Last Post: October 1st 2008, 10:02 AM

Search Tags


/mathhelpforum @mathhelpforum