MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Two successive FindMinimum -> Bug?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74335] Re: Two successive FindMinimum -> Bug?
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Mon, 19 Mar 2007 01:59:57 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <etik3j$j32$1@smc.vnet.net>

Dmitry Garanin wrote:
> Hi All,
> 
> I am trying to solve a problem that requires application of FindMinimum (or similar rutines two times and it does not work. Here is a simplified example:
> 
> 
> fxt[x_,t_]=(x^2-t)^2  (* Searching for a minimal t for which fxt turns to zero *)
> tminx[x_]:=t/.FindMinimum[fxt[x,t],{t,1}][[2]] (* Finding the minimizing t for a given x *)
> tminabs=FindMinimum[tminx[x],{x,1}]  (* Minimizing this t with respect to x. The result should be tminabs=0 at x=0 *)
> 
> The last command here does not work since, evidently tminx[x] (that is x^2 for us humans) is not treated as a regular function.
> 
> Is there a bug here or I am doing something wrong??

As written, your code cannot work.

In[1]:=
Remove[fxt, tminx, tminabs];
fxt[(x_)?NumericQ, (t_)?NumericQ] := (x^2 - t)^2;
tminx[(x_)?NumericQ] := t /. FindMinimum[fxt[x, t], {t, 1}][[2]];
tminabs = FindMinimum[tminx[x], {x, 1}]

  FindMinimum::"lstol" : "The line search decreased the step size to 
within tolerance specified by AccuracyGoal and PrecisionGoal but was 
unable to find a sufficient decrease in the function. You may need more 
than (MachinePrecision) digits of working precision to meet these 
tolerances. More...

Out[4]=
{0.00309089, {x -> 0.0555958}}

So you can try to switch to arbitrary precision,

In[5]:=
Remove[fxt, tminx, tminabs];
fxt[(x_)?NumericQ, (t_)?NumericQ] := (x^2 - t)^2;
tminx[(x_)?NumericQ] := t /. FindMinimum[fxt[x, t], {t, 1}][[2]];
tminabs = FindMinimum[tminx[x], {x, 1}, WorkingPrecision -> 20]

  FindMinimum::"lstol" : "The line search decreased the step size to 
within tolerance specified by AccuracyGoal and PrecisionGoal but was 
unable to find a sufficient decrease in the function. You may need more 
than (MachinePrecision) digits of working precision to meet these 
tolerances. More...

  FindMinimum::"fmgz" : "Encountered a gradient which is effectively 
zero. The result returned may not be a minimum; it may be a maximum or a 
saddle point. More...

Out[8]=
{1.0000000000000000000, {x -> 1.0000000000000000000}}

The last message should ring a bell. Moreover, why use two calls to 
FindMinimum when one is enough?

In[9]:=
Chop[FindMinimum[(x^2 - t)^2, {x, 1}, {t, 1}]]

  FindMinimum::"fmgz" : "Encountered a gradient which is effectively 
zero. The result returned may not be a minimum; it may be a maximum or a 
saddle point. More...

Out[9]=
{0, {x -> 1., t -> 1.}}

The graph of the function may shed some light on the issue:

In[10]:=
Plot3D[(x^2 - t)^2, {x, 0, 1}, {t, 0, 1}, AxesLabel -> {"x", "t", None}];

[...graphic deleted...]

Regards,
Jean-Marc



  • Prev by Date: Re: NDSolve doesn't stop
  • Next by Date: Re: Possible bug in NSolve[equation, variable, precission] 2
  • Previous by thread: Re: Two successive FindMinimum -> Bug?
  • Next by thread: Definite Integration vs Newton-Leibniz formula