Re: Re: FindRoot question
- To: mathgroup at smc.vnet.net
- Subject: [mg29951] Re: [mg29906] Re: FindRoot question
- From: "Mr. Wizard" <gleam at flashmail.com>
- Date: Thu, 19 Jul 2001 03:57:17 -0400 (EDT)
- References: <9j05h0$esi$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Chris, unless I don't understand your function, which wouldn't be a first, I think you're using a needlessly long and complex function. Try this one instead: NumberListQ = If[ListQ@#, And @@ NumberQ /@ #, False] &; Paul >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