MathGroup Archive 2007

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

Search the Archive

Re: A problem with FindRoot

  • To: mathgroup at
  • Subject: [mg83784] Re: [mg83728] A problem with FindRoot
  • From: Murray Eisenberg <murray at>
  • Date: Fri, 30 Nov 2007 05:25:20 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <>
  • Reply-to: murray at

You didn't say what error message Mathematica 5.2 gives.

In Mathematica 6.0.1 (and probably in 5.2 as well), the first thing is 
to ensure that you use numeric values only, so define:

   f[x_?NumericQ] := Last@First@FindRoot[y^3 + 1 == x, {y, x}]

(Except for the ?NumericQ qualification on x, this accomplishes the same 
thing you had.)  This eliminates the error message:

   FindRoot::srect: "Value x in search specification {y,x} is not a 
number or array of numbers. "

Next, just

   FindRoot[f[x], {x, 3}]

generates a different error message, namely:

   FindRoot::lstol: The line search decreased the step size to within \
tolerance specified by AccuracyGoal and PrecisionGoal but was unable \
to find a sufficient decrease in the merit function.  You may need \
more than MachinePrecision digits of working precision to meet these \

So do what the error message suggests: increase the allowed number of 
iterations or accuracy goal.  For example:

   FindRoot[f[x], {x, 3}, AccuracyGoal -> 10^-16]

Does this help?

Vassilis Dimitrakas wrote:
> Hi All,
> I'd like some help with respect to a problem I have with the FindRoot, 
> NSolve and FindInstance functions.
> My version of Mathematica is 5.2
> I define the function f as follows:
> f[x_]:={
> y/.FindRoot[y^3+1==x,{y,x}][[1]]
> }[[1]]
> f[x] returns the root of the equation y^3 + 1 == x, i.e. the value 
> (x-1)^(1/3). f[x] has obviously a
> unique root at x=1.
> If I now try to find f[x]'s root with FindRoot, for example like
> FindRoot[f[x]==0,{x,3}]
> Mathematica (v 5.2) returns error messages and no solution. The same 
> happens if I use instead NSolve
> or FindInstance. Can you guys explain why this happens and suggest a 
> remedy?
> Thanks,
> Vassilis

Murray Eisenberg                     murray at
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

  • Prev by Date: Re: Re: Re: PlotLabel - SubscriptBox - Vers.
  • Next by Date: Re: optimization routine using conjugate gradient (or other) method?
  • Previous by thread: A problem with FindRoot
  • Next by thread: Re: A problem with FindRoot