Re: using FindRoot with a list of starting values
- To: mathgroup at smc.vnet.net
- Subject: [mg25770] Re: [mg25757] using FindRoot with a list of starting values
- From: BobHanlon at aol.com
- Date: Sun, 22 Oct 2000 23:30:04 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 10/21/2000 3:34:44 PM, SLu at crai.com writes: >Here is the problem. I need to solve a simultaneous equation system using >FindRoot. For example, there are 3 equations and 3 unknowns, > >FindRoot[{eq1, eq2, eq3},{x,x0},{y,y0},{z,z0}] > >However, when I have many unknowns, it is awkward to type in all the >starting values by hand. Also, if I need to change the starting values >in >the middle of the program, or even change the number of unknowns to solve >for, I need to find out a more elegant way to provide inputs to FindRoot. > >I tried the following. First, I built a list, > >start={{x,x0},{y,y0},{z,z0}}. > >Then, I use the command > >FindRoot[{eq1,eq2,eq3},start]. > >It did not work because start is a Table. > >Can someone teach me a trick to make it work? start = {#, 1.0} & /@ {x, y, z}; eqn1 = 5x + 3y - 6z == 0; eqn2 = 2x + 3y^2 - 7 == 0; eqn3 = 7x - 5y + 2z == 0; soln = FindRoot[{eqn1, eqn2, eqn3}, Evaluate[Sequence @@ start]] {x -> 0.6375724203514085, y -> 1.3814069107613853, z -> 1.2220138056735332} And @@ ((Chop[#[[1]] /. soln] == 0) & /@ {eqn1, eqn2, eqn3}) True Bob Hanlon