MathGroup Archive 2008

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

Search the Archive

FindMaximum query

  • To: mathgroup at
  • Subject: [mg85530] FindMaximum query
  • From: "E. Neely Atkinson" <eatkinso at>
  • Date: Wed, 13 Feb 2008 04:21:29 -0500 (EST)

Consider the following function:

fun[x_] :=
  {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 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

  • Prev by Date: Re: more looping trouble
  • Next by Date: Re: Re: How should I start with mathematica?
  • Previous by thread: Re: Differential Equation
  • Next by thread: Re: FindMaximum query