MathGroup Archive 2001

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

Search the Archive

Re: FindRoot question


Just a follow-up on my own question.  Part of the problem was that I
was calling another homemade function that used FindRoot from within
FindRoot.  Problems arose when the inner FindRoot got non-numeric
values for its options.  From other messages I found that using
_?NumberQ for the inside function should help, but I was passing my
options as a list, which would not make it by  _?NumberQ.  _?ListQ
didn't help either, because {x,y} counts as a list as well as {1,2}. 
I ended up writing the following test for a list of numbers, which
helped.

ListOfNumbersQ[list_]:=Module[{n,ret},
If[ListQ[list]==False,ret=False,
n=Length[list];
ret=True;
Do[
If[NumberQ[list[[i]]]==False,ret=False]
,{i,1,n}];];
Return[ret]; ];

Thus:

In[21]:=
ListOfNumbersQ[{1,2}]

Out[21]=
True

In[23]:=
ListOfNumbersQ[{x,y}]

Out[23]=
False

My inside function then begins:

neq[xopts_?ListOfNumbersQ,ni_]:=Module[ ...

-- Chris


  • Prev by Date: Re: A question on machine numbers
  • Next by Date: Proof For Cov. Matrix equation?
  • Previous by thread: Re: FindRoot question
  • Next by thread: Re: Re: FindRoot question