Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15648

Re: Parculiarities of FindRoot

From "Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Parculiarities of FindRoot
Date 2011-02-01 11:53 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ii8s75$2mc$1@smc.vnet.net> (permalink)
References <ii5rjj$fit$1@smc.vnet.net>

Show all headers | View raw


You define Func such that it only works for numeric input (try giving
it a symbolic input and see what happens).

One of the first steps  of FindRoot involves the symbolic evaluation
of the function to find the derivative, which in this case is
unsuccessful. Changing the definition of Func slightly, so that it
tests for its arguments being numeric helps:

In[24]:= ClearAll[Func];
Func[y_?NumericQ] := x^2 /. FindRoot[x + y == 0, {x, 0.}]
Func[.2]
FindRoot[Func[z] == 0, {z, 0.}]

Out[26]= 0.04

Out[27]= {z -> 0.}

Cheers -- Sjoerd


On Jan 31, 9:24 am, Tianhui Li <tianh...@princeton.edu> wrote:
> Here's a question for the group: in the following function, Func seems
> to evaluate numerical arguments correctly and *works* when you throw
> it into a FindRoot.  But the second command generates a lot of warning
> messages.  Does anyone understand why?
>
> Func[y_] := x^2 /. FindRoot[x + y == 0, {x, 0.}]
> Func[.2]
> FindRoot[Func[z], {z, 0.}]
>
> Warm Regards,
> Michael Li
> Bendheim Center for Finance
> Princeton University
> Princeton, NJ 08544

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Parculiarities of FindRoot "Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com> - 2011-02-01 11:53 +0000

csiph-web