Re: FindRoot for the determinant of a matrix with a varying size
- To: mathgroup at smc.vnet.net
- Subject: [mg59732] Re: FindRoot for the determinant of a matrix with a varying size
- From: "Nasser Abbasi" <nma at 12000.org>
- Date: Fri, 19 Aug 2005 04:31:55 -0400 (EDT)
- References: <de13n4$8so$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Wonseok Shin" <wssaca at gmail.com> wrote in message news:de13n4$8so$1 at smc.vnet.net... > > Hello everyone, > > I am a user of Mathematica 5.1 for Mac . > I defined the function using the determinant of a matrix of a > varying > size. Even though this function is well-behaving, it seems that > FindRoot cannot deal this function. Please look at the following > code: > > ------------------------------------------------- > In[1]:= > f[x_] := Det[Table[Exp[(i - j)/x]/x , {i, 2, 5, x}, {j, 2, 5, x}]] > > In[2]:= > Plot[f[x], {x, 3, 30}] > ------------------------------------------------- > > By running the above Plot command, you can see clearly that the > function f is very smooth in the interval 3< x < 30, and f[x] == 0.1 > has a solution in 5 < x < 15. > > But I've failed to find a solution of f[x] == 0.1 using FindRoot: > > ------------------------------------------------- > In[3]:= > FindRoot[f[x] == 0.1, {x, 5}] > > Table::iterb : Iterator {i, 2, 5, x} does not have appropriate > bounds. > ------------------------------------------------- > > Is there any workaround for this problem? > > Thanks, > > Wonseok Shin > > Interesting problem. If you change the definition to accept only argument x to be of type number, then the error message goes away. Without that, 'x' was not being bounded to the argument of f[x_], and so the upper limit of the iterator inside the Table call was still a free variable (has no value) and hence the error message. Weird one. I am using 5.2. any way, this fix below removes the error message. In[20]:= Remove["Global`*"] f[x_?NumberQ] := Det[Table[Exp[(i - j)/x]/x, {i, 2, 5, x}, {j, 2, 5, x}]] FindRoot[f[x] == 0.1, {x, 5}] Out[22]= {x -> 10.} Nasser