Re: NMinimize a function of NMaximize

*To*: mathgroup at smc.vnet.net*Subject*: [mg79971] Re: NMinimize a function of NMaximize*From*: ben <benjamin.friedrich at gmail.com>*Date*: Fri, 10 Aug 2007 01:38:44 -0400 (EDT)*References*: <f9endl$meh$1@smc.vnet.net>

Hi Saptarshi, Your problem seems to be the use of symbolic expressions, where your need numeric values. Try this xopt[p_?NumericQ]:=First@NMaximize[{d[x,p,3],0\[LessEqual]x\ [LessEqual]1},x] NMinimize[{xopt[p],0\[LessEqual]p\[LessEqual]1},p] Bye ben On 9 Aug., 11:40, sapsi <saptarshi.g... at gmail.com> wrote: > I have a function > g[x_]:=1 (Pi - 2 x*Sqrt[1 - x^2] - 2 ArcSin[x]) > d[x_, o_, n_] := Abs[g[x] - Normal[Series[g[y], {y, o, n}]]] /. y -> x > > d[] is the absolute difference of g[] and its Taylor series > approximation > > dm[p_] := NMaximize[{d[x, p, 3], 0 <= x <= 1}, x][[1]] > > dm[] is the maximum absolute difference between the Taylor series > approximation(3rd order) around p and g[]. > I wish to find that value of 'p' that minimizes this maximum > difference - i tried plotting and can see where the minima occurs but > would like the exact value. So, it thought this would work > > NMinimize[{NMaximize[{ d[x, p, 3], 0 <= x <= 1}, x], 0 <= p <= 1}, p]. > Instead i get errors (briefly) > > NMaximize::nnum: The function value -Abs[-2.41057-(2 (<<19>>-p)^2 \ > p)/Sqrt[1-p^2]+2 p Sqrt[1-p^2]+(2 (<<1>>)^3)/(3 Sqrt[1-<<1>>] \ > (-1+p^2))-(4 (0.652468-p) (-1+p^2))/Sqrt[1-p^2]+2 ArcSin[p]] is not a > \ > number at {x} = {0.652468}. >> > NMaximize::nnum: "The function value \ > -Abs[-2.41057-(2\(<<19>>-p)^2\p)/Sqrt[1-p^2]+2\ p\ Sqrt[1-p^2]+(2\(<<\ > 1>>)^3)/(3\Sqrt[1-<<1>>]\(-1+p^2))-(4\(0.652468-p)\(-1+p^2))/Sqrt[1-p^ > \ > 2]+2\ ArcSin[p]] is not a number at {x} = {0.6524678079740285`}." > NMaximize::nnum: The function value -Abs[-2.41057-(2 (<<19>>-p)^2 \ > p)/Sqrt[1-p^2]+2 p Sqrt[1-p^2]+(2 (<<1>>)^3)/(3 Sqrt[1-<<1>>] \ > (-1+p^2))-(4 (0.652468-p) (-1+p^2))/Sqrt[1-p^2]+2 ArcSin[p]] is not a > \ > number at {x} = {0.652468}. >> > NMinimize::nnum: > > Can anyone provide any pointers on how to find the minimum of dm[]? > Thank you for your time > Saptarshi