Re: FindMaximum query
- To: mathgroup at smc.vnet.net
- Subject: [mg85559] Re: FindMaximum query
- From: Daniel Huber <dh at metrohm.ch>
- Date: Wed, 13 Feb 2008 07:25:52 -0500 (EST)
- References: <foudug$m07$1@smc.vnet.net>
Hi Neely, deine fun like: fun[x_?NumericQ] hope this helps, Daniel E. Neely Atkinson wrote: > Consider the following function: > > fun[x_] := > Module[ > {y, sol}, > sol = FindRoot[Sqrt[y] == Abs[x], {y, 0, 0.001}]; > (* AppendTo[list, sol]; *) > -y /. sol[[1]] > ] > > Then Plot[fun[x], {x, -2, 2}] works fine, but > > FindMaximum[fun[x], {x, 1, 1.001}] > > fails. If I uncomment the debug line in fun and execute > > list = {}; > FindMaximum[fun[x], {x, 1, 1.001}] > > Then list contains > > {FindRoot[Sqrt[y$21471] == Abs[x], {y$21471, 0, 0.001}]} > > > So, FindRoot fails because x is passed through unevaluated, I think. > I would appreciate any advice on how to get FindMaximum (or NMaximize) > to work in this case. > > Mathematic 6.0.1.0 x86 32 bit > Mac OS X 10.4.11 > > Thanks very much, > > E. Neely Atkinson > Department of Biostatistics > M. D. Anderson Cancer Center > > neely at pdq.net >