Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11236

Re: Problem finding maximum

From Frank K <fkampas@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Problem finding maximum
Date 2012-08-05 22:05 +0000
Message-ID <jvmqnl$a9c$1@smc.vnet.net> (permalink)
References <20120805014915.A5ED5684F@smc.vnet.net> <jvl4bt$77r$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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@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.}}

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: Problem finding maximum Bob Hanlon <hanlonr357@gmail.com> - 2012-08-05 06:37 +0000
  Re: Problem finding maximum Frank K <fkampas@gmail.com> - 2012-08-05 22:05 +0000

csiph-web