MathGroup Archive 2009

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

Search the Archive

Re: Query about using FindRoot on function defined via Module

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102856] Re: Query about using FindRoot on function defined via Module
  • From: Harutyun Amirjanyan <amirjanyan at gmail.com>
  • Date: Sat, 29 Aug 2009 06:34:12 -0400 (EDT)
  • References: <h77n8k$s1h$1@smc.vnet.net>

As you can find in help FindRoot (like Plot) first localizes the
values of all variables, then evaluates f with the variables being
symbolic, and then repeatedly evaluates the result numerically.

to prevent this you can use Evaluated -> False option
(this somewhy isn't documented. see http://web.ift.uib.no/~szhorvat/mmatricks.php)

F[x_] := Module[{t}, NIntegrate[t, {t, 0, x}] - 2]
FindRoot[F[x], {x, 0.2}, Evaluated -> False]

or define your function only for numbers

F1[x_?NumberQ] := Module[{t}, NIntegrate[t, {t, 0, x}] - 2]
FindRoot[F1[x], {x, 0.2}]


  • Prev by Date: Re: random variable
  • Next by Date: Problem with ColorFunction in ListDensityPlot in version 7
  • Previous by thread: Query about using FindRoot on function defined via Module
  • Next by thread: Eigenvalues broken?