MathGroup Archive 2006

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

Search the Archive

Re: How to use NMinimize with a numerical function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65429] Re: How to use NMinimize with a numerical function
  • From: Peter Pein <petsie at dordos.net>
  • Date: Fri, 31 Mar 2006 06:09:31 -0500 (EST)
  • References: <e0gd79$i8v$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Darren Glosemeyer schrieb:
> The behavior you have noticed is described in the following Technical 
> Support FAQ.
> 
> http://support.wolfram.com/mathematica/mathematics/numerics/nsumerror.html
> 
> NumericQ constraints can be imposed on its arguments to keep f from 
> evaluating before the arguments are numeric, and the FindMinimum call will 
> evaluate as expected.
> 
> 
> In[1]:= f[a_?NumericQ,b_?NumericQ,c_?NumericQ]:=
>             Module[{x}, NMinimize[{(a x^2 + b x + c)^2}, x][[2, 1, 2]]]
> 
> In[2]:= FindMinimum[(f[r, s, t] + 2.0)^2, {{r, -5, 5}, {s, -5, 5}, {t, -5, 5}}]
> 
> NMinimize::cvmit: Failed to converge to the requested accuracy or precision 
> within 100
>       iterations.
> 
>                     -23
> Out[2]= {2.08333 10   , {r -> -1.25, s -> -5., t -> -5.14745}}
> 
> 
> Darren Glosemeyer
> Wolfram Research
> 
> 
> At 04:05 AM 3/28/2006 -0500, Marco Gabiccini wrote:
>> Hi all,
>>
>> I wanted to test NMinimize[] with a numerical function whose return value
>> is the result of another NMinimize.
>> I defined the intersection with the abscissa of the parabola y=ax^2+bx+c as
>> f[a,b,c]
>> and I want to find one set of values {a,b,c} for which that intersection is
>> reached at x=-2.
>>
>> I defined
>>
>> f[a_, b_, c_] :=
>>    Module[{x}, NMinimize[{(a x^2 + b x + c)^2}, x][[2, 1, 2]]]
>>
>> and I would like to find that particular value of {a,b,c} for which
>> f[a,b,c]=-2, that is why I call
>>
>> FindMinimum[(f[r, s, t] + 2.0)^2, {{r, -5, 5}, {s, -5, 5}, {t, -5, 5}}]
>>
>> but I get this error message
>> 1760692.jpg
>>
>> [Attachments are not permitted.  Please contact the author to
>> obtain this - moderator]
>>
>> It seems that the latter FindMinimum[] keeps the r,s,t unevaluated when
>> calling f in the first FindMinimum. Is there a way to switch the order of
>> evaluation?
>>
>> Can anybody help me?
>>
>> Marco
> 
Hi Marco

isn't it faster in this case to use the capabilities of Reduce[]?

please have a look at http://people.freenet.de/Peter_Berlin/Mathe/reduceToPiecewise.nb

Cheers,
   Peter


  • Prev by Date: Re: Beginner--problem with typesetting
  • Next by Date: Re: Bug with Series[] - help wanted
  • Previous by thread: Re: How to use NMinimize with a numerical function
  • Next by thread: mod function and AKS paper