Re: Using FindRoot on a numerical vector-valued function
- To: mathgroup at smc.vnet.net
- Subject: [mg41140] Re: [mg41123] Using FindRoot on a numerical vector-valued function
- From: Bobby Treat <drmajorbob+MathGroup3528 at mailblocks.com>
- Date: Mon, 5 May 2003 02:43:10 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Here are some examples:
f[a_, b_, c_] := Cross[{a, b, c}, {-1, 1, -1}]
Thread[f[a, b, c] - {0, 0, 0}]
FindRoot[%, {a, -2}, {b, -2}, {c, -2}]
FindRoot[%%, {a, {-1, 1}}, {b, {-1, 1}}, {c, {-1, 1}}]
FindRoot[%%%, {a, -1, 1}, {b, -1, 1}, {c, -1, 1}]
{-b - c, a - c, a + b}
{a -> -2., b -> 2., c -> -2.}
{a -> -1., b -> 1., c -> -1.}
{a -> -1., b -> 1., c -> -1.}
The third call to FindRoot uses an undocumented form of the arguments
so, although it works, I don't recommend it.
Bobby
-----Original Message-----
From: Randall Beer <beer at eecs.cwru.edu>
To: mathgroup at smc.vnet.net
Subject: [mg41140] [mg41123] Using FindRoot on a numerical vector-valued function
Suppose I have a function F that takes N arguments and returns a
length-N vector: F[1,2,3] => {-1.1,2.08,0.03}. This function involves
numerically computing an object and then returning certain components
of
that object, so it cannot be expanded with symbolic arguments (e.g.,
F[x,y,z] will not work).
I need to find the arguments that make F return a vector of all 0s.
That is, I would like to do something like:
FindRoot[F[y1, y2, y3], {y1, -1, 1}, {y2, -1, 1}, {y3, -1, 1}]
Unfortunately, this doesn't work because FindRoot wants 3 things, not a
function returnning a vector of 3 things
I could do
FindRoot[{F1[y1, y2, y3] == 0, F2[y1, y2, y3] == 0, F3[y1, y2, y3] ==
0}, . . .]
but then I would have to numerically recompute the object 3 times.
Any suggestions would be greatly appreciated.