MathGroup Archive 2007

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

Search the Archive

Re: minmum of a function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg75349] Re: minmum of a function
  • From: Peter Pein <petsie at dordos.net>
  • Date: Thu, 26 Apr 2007 03:30:06 -0400 (EDT)
  • References: <f014ar$8qr$1@smc.vnet.net> <f0ejkm$pad$1@smc.vnet.net>

skruege at gwdg.de schrieb:
> Hi Jean-Marc,
> 
> Thank for your help.
> I think (Head /@ t1)[[All,1]] is exactly what I need.
> Probably I could simplify my definitions of function even before.
> In fact, I defined
> 
> amp := fmax/f5
> 
> with fmax := FindMaximum[Sum[Integrate[f1[x], {x, i, i + a}], {i, 0, 2}],
> {p, 0}] whereas f1[x_] := c + (Cos[Pi*x + p])^2
> and
> f5 := Integrate[f4[x], {x, 0, 2 + a}] whereas f4[x_] := c + (Cos[Pi*x +
> pmax])^2 and pmax := p  /. fmax[[2]].
> 
> With (Head /@ t1)[[All,1]] I'm now able to create a list amp[a] and to
> plot it.
> Before your help, I managed to get the list by using 'Block' like f6 :=
> Block[{a = 0.1}, amp], but it isn't elegant at all.
> 
> Regards,
> Sven
> 

Hi Sven,

I think you should try to find an explicit expression for amp. Then each call
to amp will be faster.

If amp := fmax/f5 then am will be of the form
{number1/number3,{(p->number2)/number3}}, which does not make much sense to
me. amp:=fmax[[1]]/f5 would be more meaningful, if the handling of the
parameters was sufficient (sorry).

I tried the following and had to do some assumptions:

I'll assume 0<a<1 and pmax<0

In[1]:=
f1and4[x_, p_] := c + Cos[Pi*x + p]^2
In[2]:=
targetToMaximize = FullSimplify /@ Apart[Sum[Integrate[f1and4[x, p], {x, i, i
+ a}],
     {i, 0, 2}], a]
Out[2]=
(3/2)*a*(1 + 2*c) + (3*Cos[2*p + a*Pi]*Sin[a*Pi])/(2*Pi)
In[3]:=
redu = Module[{t1 = Simplify[D[targetToMaximize, p]], t2},
   t2 = Simplify[D[t1, p]];
   Assuming[0 < a < 1, FullSimplify[
      Reduce[t1 == 0 > t2], p, Reals]]]]
Out[3]=
(C[1] | C[2]) \[Element] Integers &&
   ((p + (a*Pi)/2 == Pi*C[1] && 0 < a - 2*C[2] < 1) ||
   (-1 < a - 2*C[2] < 0 && p == ArcTan[Cot[(a*Pi)/2]] + Pi*C[1]))
In[4]:=
sol = Solve[FullSimplify[redu /. {C[1 | 2] -> 0}, 0 < a < 1], p]
Out[4]=
{{p -> -((a*Pi)/2)}}
In[5]:=
pmax = p /. sol[[1]]
Out[5]=
-((a*Pi)/2)
In[6]:=
fmax = targetToMaximize /. p -> pmax
Out[6]=
(3/2)*a*(1 + 2*c) + (3*Sin[a*Pi])/(2*Pi)
In[7]:=
f5[a_] = Integrate[f1and4[x, pmax], {x, 0, 2 + a}]
Out[7]=
((2 + a)*(1 + 2*c)*Pi + Sin[a*Pi])/(2*Pi)
In[8]:=
amp[a_] = FullSimplify[fmax/f5[a]]
Out[8]=
(3*(a*(1 + 2*c)*Pi + Sin[a*Pi]))/((2 + a)*(1 + 2*c)*Pi + Sin[a*Pi])
In[9]:=
Plot[amp[a] /. c -> 0.3, {a, 0, 1}]

hth,
Peter



  • Prev by Date: Re: "hard" simplification
  • Next by Date: Re: Numerical calculation of a double sum (Appell's function F4)
  • Previous by thread: Re: Re: minmum of a function
  • Next by thread: Re: minmum of a function