Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: problems with NMinimize

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109370] Re: problems with NMinimize
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 23 Apr 2010 03:51:01 -0400 (EDT)

Define a function that only evaluates for numeric arguments

f[a_?NumericQ, b_?NumericQ] :=
 Abs[NIntegrate[Sin[x], {x, -a, b}]]^2

NMinimize[f[a, b], {a, b}]

{7.56317*10^-19,{a->0.131888,b->-0.131888}}


Bob Hanlon

---- Neil Broderick <ngb at ecs.soton.ac.uk> wrote: 

=============
Hi,
I am trying to use NMinimize to find the solutions to various numerical equations and I keep getting error
messages concerning non-numerical values. For example consider the following:

In[2]:= NMinimize[Abs[NIntegrate[Sin[x], {x, -a, b}]]^2, {a, b}]

During evaluation of In[2]:= NIntegrate::nlim: x = -1. a is not a valid limit of integration. >>

During evaluation of In[2]:= NIntegrate::nlim: x = -1. a is not a valid limit of integration. >>

During evaluation of In[2]:= NIntegrate::nlim: x = -1. a is not a valid limit of integration. >>

During evaluation of In[2]:= General::stop: Further output of NIntegrate::nlim will be suppressed during this calculation. >>

Out[2]= {5.08978*10^-24, {a -> 0.0994414, b -> 0.0994414}}

My actual problem involves taking Fourier transforms of lists of numbers but you get the picture. Why is
NMinimize putting variables into the function rather than just numbers and is the likely to cause a problem
in some cases?

regards,
Neil=




  • Prev by Date: Speed Up Routines
  • Next by Date: Re: problems with NMinimize
  • Previous by thread: problems with NMinimize
  • Next by thread: Re: problems with NMinimize