Re: FindRoot for the determinant of a matrix with a varying size
- To: mathgroup at smc.vnet.net
- Subject: [mg59731] Re: FindRoot for the determinant of a matrix with a varying size
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Fri, 19 Aug 2005 04:31:53 -0400 (EDT)
- Organization: The University of Western Australia
- References: <de13n4$8so$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <de13n4$8so$1 at smc.vnet.net>,
"Wonseok Shin" <wssaca at gmail.com> wrote:
> 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}]
You might notice that this plot is, trivially, just a plot of 1/x. Why?
Because for x > 3, the iterator only takes on the value i = j = 2 and
the table consists of just one element: 1/x.
So, is this really the definition you intended? Note that the last entry
in the iterator {i, 2, 5, x} is the step-size, not the number of points.
That would be specified by
(5 - 2)/x == 3/x
which is what I expect you might be want.
> -------------------------------------------------
>
> 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?
This is a FAQ. The functions you pass to FindRoot need to restricted so
as to evaluate only for numerical arguments. Notwithstanding my concerns
about your original definition, you would write
Clear[f];
f[x_?NumericQ] :=
Det[Table[Exp[(i - j)/x]/x , {i, 2, 5, x}, {j, 2, 5, x}]]
FindRoot[f[x] == 0.1, {x, 5}]
Cheers,
Paul
_______________________________________________________________________
Paul Abbott Phone: 61 8 6488 2734
School of Physics, M013 Fax: +61 8 6488 1014
The University of Western Australia (CRICOS Provider No 00126G)
AUSTRALIA http://physics.uwa.edu.au/~paul