[Date Index]
[Thread Index]
[Author Index]
Re: A problem with FindRoot
*To*: mathgroup at smc.vnet.net
*Subject*: [mg83789] Re: A problem with FindRoot
*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
*Date*: Fri, 30 Nov 2007 05:28:03 -0500 (EST)
*Organization*: The Open University, Milton Keynes, UK
*References*: <fim7qp$qqp$1@smc.vnet.net>
Vassilis Dimitrakas wrote:
> 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?
I bet that the error messages you get are a similar to "FindRoot::srect:
"Value x in search specification {y,x} is not a number or array of numbers."
Add a condition to your definition of f so it is called only for numeric
arguments.
In[1]:= Clear[f]
f[x_?NumberQ] := {y /. FindRoot[y^3 + 1 == x, {y, x}][[1]]}[[1]]
FindRoot[f[x] == 0, {x, 3}, AccuracyGoal -> 5]
Out[3]= {x -> 1.}
Regards,
--
Jean-Marc
Prev by Date:
**Re: Manipulate is sluggish?**
Next by Date:
**Re: Re: PlotLabel - SubscriptBox - Vers. 6: FontColor not**
Previous by thread:
**Re: A problem with FindRoot**
Next by thread:
**TwoAxisListPlot for V6?**
| |