[Date Index]
[Thread Index]
[Author Index]
Re: Strange quirk to FindMinimum
*To*: mathgroup at smc.vnet.net
*Subject*: [mg8477] Re: [mg8454] Strange quirk to FindMinimum
*From*: David Withoff <withoff>
*Date*: Tue, 2 Sep 1997 16:15:15 -0400
*Sender*: owner-wri-mathgroup at wolfram.com
> In Mathematica 3.0 I try to minimize a function. I run into some
> problems which probably can be avoided by renaming the variables, but I
> think that it is puzzling enough to post it to this group. By the way,
> thanks to all the people who helped me get rid of outer braces by.
>
> In[]:= f = Log[\[Lambda]]^2 + x[1]^2;
> In[]:= FindMinimum[Evaluate[f],{x[1],1},{\[Lambda],2}]
> Out[]:= {6.47493078439917812`*^-19, {x[1] \[Rule]
> 7.42323767889736974`*^-11,
> \[Lambda] \[Rule] 0.999999999198761813`}}
>
> Really nice and neat. Then I remove the square of the x[1]:
>
> In[]:= f = Log[\[Lambda]]^2 + x[1];
> In[]:= FindMinimum[Evaluate[f],{x[1],1.},{\[Lambda],2.}]
> error: Function::"flpar": Parameter specification {x[1], \[Lambda]}
> in Function[{x[1], \[Lambda]}, Log[\[Lambda]]^2 + x[1]] should be a
> symbol or a list of symbols.
>
> Hm. that really doesn't make any sense to me.
>
> Now I change x[1] to x and \[Lambda] to y:
>
> In]}:= f = Log[y]\^2 + \ x;
> In[]:= FindMinimum[Evaluate[f],{x,1.},{y,2.}]
> error: FindMinimum::"fmnum": Objective function -13.43 + 1.07 I
> is not real at {x, y} = {-3.59,-1.18}
> Out[]:= FindMinimum[Evaluate[f],{x,1.},{y,2.}]
>
> This is a reasonable answer from mathematica I think, so I will try and
> change my fancy greek variable names to latin ones. But if any of you
> can understand it I will appreciate the insight. Otherwise I might send
> it to Wolfram.
>
> Happy Computing,
> Nikolaj
> --------------------------------------------------------------
> | Ph.D. stud., cand.scient. |
> | K. Nikolaj Berntsen |
> | Office: Department of Structural Engineering and Materials |
> | Technical University of Denmark |
> | Building 118, room 152 |
> | DK-2800 Lyngby |
> | Tel +45 4525 1769 |
> | Fax +45 4588 3282 |
> j--------------------------------------------------------------
You don't need to avoid using fancy Greek variable names. They
will work just fine in a calculation like this.
You can also use normal expressions like x[1] as variables. That
isn't the problem either.
The problem is that the expression
f = Log[y]^2 + x
doesn't have a minimum as a function of x. Since this problem doesn't
have a solution, the FindMinimum function will eventually give up
trying to find one.
The specific mechanism for giving up in this example is that FindMinimum
correctly ends up trying to evaluate the objective function at a point
where the objective function is not a real number. In an effort to
find out if this non-real is just a limitation of compiled evaluation
(FindMinimum uses compiled evaluation by default), Mathematica
automatically tries the same calculation using a pure function, and
uncompiled evaluation. That leads to the first warning message:
Function::flpar:
Parameter specification {\[Lambda], x[1]} in
Function[{\[Lambda], x[1]}, {f}] should be a symbol or a list of symbols.
because the variables in a pure function must be symbols. The next
message is more directly related to the cause of the problem:
FindMinimum::fmnum:
Objective function {2., 1.} is not real at {\[Lambda], x[1]} = {2., 1.}.
but the real problem is that this function doesn't have a minimum.
If you turn off compiled evaluation using Compiled -> False, then the
initial messages will go away, but since the problem doesn't have
a solution, the FindMinimum function will still give up.
In[3]:= f = Log[\[Lambda]]^2 + x[1];
In[4]:= FindMinimum[f, {\[Lambda], 2}, {x[1], 1}, Compiled -> False]
FindMinimum::fmnum:
Objective function -13.43777467497571 + 1.075694762367751 I is not real at
{\[Lambda], x[1]} = {-1.18673, -3.59748}.
Out[4]= FindMinimum[f, {\[Lambda], 2}, {x[1], 1}, Compiled -> False]
This is one of the few examples of a calculation in Mathematica where
the first in a series of warning messages is not the most important one.
Dave Withoff
Wolfram Research
Prev by Date:
**RE: Flat: Problems & Workarounds Sweden.**
Next by Date:
**prograMing: create a cycled matrix**
Previous by thread:
**Re: Flat: Problems & Workarounds Sweden.**
Next by thread:
**prograMing: create a cycled matrix**
| |