Re: Finding the Local Minima of a somewhat complicated function
- To: mathgroup at smc.vnet.net
- Subject: [mg116021] Re: Finding the Local Minima of a somewhat complicated function
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Sat, 29 Jan 2011 05:27:56 -0500 (EST)
I believe you can solve it for all a in one go: Clear[fun] fun[a_, y_] = (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]) // Rationalize; start = 10^(-20); end = 1 - 10^(-20); Minimize[{fun[a, y], start <= y <= end}, y] {(333000000008300000000829999999917 - 1250000000000000000000000000000 a)/ 2500000000000000000000000000000000000000, {y -> 9999999999/ 20000000000 + (\[Sqrt](8300000014980000000083 - 50000000000 a + (-333000000008300000000829999999917 + 1250000000000000000000000000000 a)/ 25000000000000000000))/(20000000000 Sqrt[83])}} Bobby On Fri, 28 Jan 2011 05:14:32 -0600, Andrew DeYoung <adeyoung at andrew.cmu.edu> wrote: > Hi, > > 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? > > Of course, it could be that the function does not have a local minimum > at those values of a where Mathematica does not find one. But, if I > plot fun at a=300, for example, the plot shows that there is a local > minimum at something like y=0.945: > > Plot[fun /. a -> 300, {y, 0, 1}] > > But if I ask Mathematica to find that local minimum... > > FindMinimum[fun /. a -> 300, {y, startPoint, endPoint}] > > ...Mathematica will not find it. > > Can you please help me understand why I am having trouble finding the > local minima? > > Many thanks in advance, > > Andrew DeYoung > Carnegie Mellon University > -- DrMajorBob at yahoo.com