[Date Index]
[Thread Index]
[Author Index]
Re: A problem with FindRoot
*To*: mathgroup at smc.vnet.net
*Subject*: [mg83783] Re: [mg83728] A problem with FindRoot
*From*: DrMajorBob <drmajorbob at bigfoot.com>
*Date*: Fri, 30 Nov 2007 05:24:46 -0500 (EST)
*References*: <3083761.1196378760049.JavaMail.root@m35>
*Reply-to*: drmajorbob at bigfoot.com
NumericQ fixes the problem (for the most part):
Clear[f]
f[x_?NumericQ] := y /. First@FindRoot[y^3 + 1 == x, {y, x}]
FindRoot[f[x] == 0, {x, 3}]
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 \
tolerances. >>
{x -> 1.}
The precision warning occurs for a very good reason, as a plot shows:
Plot[f@x, {x, 0, 5}]
Gradient methods obviously won't work well at such a point.
In addition, you're starting the inner (first) FindRoot at y = x (the
current value). To converge in the final problem x must approach 1, but y
must approach 0, so on EVERY iteration of the inner problem you're
starting far from the solution, learning nothing from previous iterations.
FindRoot manages anyway, but only barely.
So this is no way to do things unless it's really necessary.
In this case a nice option is
Clear[f]
f[x_] = Last@
Simplify[Reduce[{y^3 + 1 == x, y \[Element] Reals}, {y}], x >= 0];
Plot[f@x, {x, 0, 5}]
Reduce[f[x] == 0, x]
x == 1
Bobby
On Thu, 29 Nov 2007 05:24:03 -0600, Vassilis Dimitrakas
<vdimitrakas at googlemail.com> 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
>
>
>
--
DrMajorBob at bigfoot.com
Prev by Date:
**Re: FindInstance puzzler**
Next by Date:
**Re: "vector" Map[] / functional outer product?**
Previous by thread:
**Re: A problem with FindRoot**
Next by thread:
**Re: A problem with FindRoot**
| |