MathGroup Archive 2011

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

Search the Archive

Re: Finding the Local Minima of a somewhat complicated function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116008] Re: Finding the Local Minima of a somewhat complicated function
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sat, 29 Jan 2011 05:25:15 -0500 (EST)

On 1/28/11 at 6:14 AM, adeyoung at andrew.cmu.edu (Andrew DeYoung)
wrote:

>I have a function that consists of two variables, y and a.  I would
>like to find the local minimum of the function in y for various
>constant values of a.

>For example, the list of a values is given by:

>atable = Range[100, 300, 5];

>For each a value in atable, I want to find the local minimum of the
>function in y.  My function is "fun," and I use code like the
>following:

>fun=(1000-5*a)/10000000000+332*(y/10000000000+(1-y)*(1/5000000000+y)
>) +(1/2)*y*(1000-5*a+1000*(-1/10))+0.695*a*(-(Log[10000000000]/
>10000000000)+(1-y)*Log[1-y]+y*Log[y]);

>startPoint = 10^(-20); endPoint = 1-10^(-20); minData =
>Table[FindMinimum[fun /. a -> j, {y, startPoint, endPoint}], {j,
>atable}]

>Above, I use startPoint=10^(-20) and endPoint=1-10^(-20) because the
>function is indeterminate at y=0 and at y=1.  When I run the above
>code, I see that for most (but not all) values of a, Mathematica
>does not find a local minimum.  Why is this so?

You are trying to find a numeric value for an expression that is
indeterminate at points very neat the starting values you have
supplied. This isn't a good idea since limitations of machine
precision arithmetic can create problems. Further, when
supplying two starting points FindMinimum is not guaranteed to
search only for values within the interval specified by those points.

Instead of using defining two starting points do:

In[12]:= FindMinimum[{fun /. a -> 300, 0 < y < 1}, y]

Out[12]= {-310.652,{y->0.945752}}

Alternatively, you could use NMinimize which uses different algorithms

In[13]:= NMinimize[{fun /. a -> 300, 0 < y < 1}, y]

Out[13]= {-310.652,{y->0.945752}}



  • Prev by Date: Re: Finding the Local Minima of a somewhat complicated function
  • Next by Date: Re: adding a keyboard shortcut for double brackets
  • Previous by thread: Re: Finding the Local Minima of a somewhat complicated function
  • Next by thread: Re: Finding the Local Minima of a somewhat complicated function