Re: Problem finding maximum

*To*: mathgroup at smc.vnet.net*Subject*: [mg127591] Re: Problem finding maximum*From*: Frank K <fkampas at gmail.com>*Date*: Sun, 5 Aug 2012 14:59:14 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*Delivered-to*: l-mathgroup@wolfram.com*Delivered-to*: mathgroup-newout@smc.vnet.net*Delivered-to*: mathgroup-newsend@smc.vnet.net*References*: <20120805014915.A5ED5684F@smc.vnet.net> <jvl4bt$77r$1@smc.vnet.net>

On Sunday, August 5, 2012 2:37:49 AM UTC-4, Bob Hanlon wrote: > f[x_, a_] = (a^3 - 6 x - a^2 (4 + x) + > > a (2 + 12 x - 4 x^2))/(8 a); > > > > aa1 = .7481; > > > > Plot[Abs[f[x, aa1]], {x, 0, aa1}] > > > > "FindMaximum[f, x] searches for a local maximum in f, starting from an > > automatically selected point." > > > > FindMaximum[{Abs[f[x, aa1]], > > 0 <= x <= aa1}, x] > > > > {0.0317268, {x -> 0.7481}} > > > > "FindMaximum[f, {x, x0}] searches for a local maximum in f, starting > > from the point x = x0." > > > > FindMaximum[{Abs[f[x, aa1]], > > 0 <= x <= aa1}, {x, .1}] > > > > {0.0540933, {x -> 1.*10^-7}} > > > > You just needed to give it a better starting value than the default. > > Alternatively, use NMaximize > > > > "NMaximize always attempts to find a global maximum of f subject to > > the constraints given." > > > > NMaximize[{Abs[f[x, aa1]], > > 0 <= x <= aa1}, x] > > > > {0.0540933, {x -> 0.}} > > > > > > Bob Hanlon > > > > > > On Sat, Aug 4, 2012 at 9:49 PM, Cisco Lane <travlorf at yahoo.com> wrote: > > > I cannot seem to find the corrrect maximum for the absolute value of the following function in 0<=x<=aa1 > > > > > > aa1 = .7481 > > > > > > f[x_, a_] = (a^3 - 6 x - a^2 (4 + x) + a (2 + 12 x - 4 x^2))/(8 a) > > > > > > For example, FindMaximum[{Abs[f[x, aa1]], 0 <= x <= aa1}, x] gives {0.0317268, {x -> 0.7481}} > > > > > > The correct answer is at x=0, where Abs[f[0,aa1]]=0.0540933 but I have tried every maximization function I can think of and nothing will give me the correct answer. Can anyone help? > > > This calculation can be done symbolically if you convert aa1 into a fraction. In[1]:= f[x_,a_]=(a^3-6 x-a^2 (4+x)+a (2+12 x-4 x^2))/(8 a) Out[1]= (a^3-6 x-a^2 (4+x)+a (2+12 x-4 x^2))/(8 a) In[2]:= aa1=Rationalize[.7481] Out[2]= 7481/10000 In[7]:= Maximize[{Abs[f[x,aa1]],0<=x<=aa1},x] Out[7]= {43274639/800000000,{x->0}} In[8]:= N[%] Out[8]= {0.0540933,{x->0.}}

**References**:**Problem finding maximum***From:*Cisco Lane <travlorf@yahoo.com>