FindRoot on fn with vble num of vbles
- To: mathgroup at smc.vnet.net
- Subject: [mg36164] FindRoot on fn with vble num of vbles
- From: John MacCormick <jmac at tuzigoot.hpl.hp.com>
- Date: Fri, 23 Aug 2002 21:34:57 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Suppose f is a function of n real variables, and returns a
vector of n real variables. What is the correct syntax to find a root
of f using FindRoot?
For instance, the following works with n=7, but I would need to change
the code if I changed the value of n:
f[p_] := Table[fk[p, k], {k,n}];
pn = {p1,p2,p3,p4,p5,p6,p7};
f1 := f[pn] [[1]];
f2 := f[pn] [[2]];
f3 := f[pn] [[3]];
f4 := f[pn] [[4]];
f5 := f[pn] [[5]];
f6 := f[pn] [[6]];
f7 := f[pn] [[7]];
theRoot = FindRoot[{f1==0,f2==0,f3==0,f4==0,f5==0,f6==0,f7==0},
{p1, 1/n},{p2, 1/n},{p3, 1/n},{p4, 1/n},{p5, 1/n},
{p6, 1/n},{p7, 1/n}];
--
John MacCormick
Systems Research Center, HP Labs, 1501 Page Mill Road,
Palo Alto, CA 94304, USA. Phone: +1 650 8572454, Fax: +1 650 8528186