MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: FindRoot and vector equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36289] Re: FindRoot and vector equations
  • From: Robert Knapp <rknapp at wolfram.com>
  • Date: Fri, 30 Aug 2002 01:19:14 -0400 (EDT)
  • Organization: Wolfram Research, Inc.
  • References: <aki1qd$ia7$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

anhjunk wrote:
> I need some help with using FindRoot. I want to solve a system of
> nonlinear equations numerically. Each equation in the system is an
> equation with vector variables. The equations are such that it is
> difficult to convert them to equations involving only the components
> of the vector variables.
> 
> I have tried the following two possibilities without success. In what
> follows I am using a MADE UP EXAMPLE. In this example it is easy to
> write the equations in terms of only the components. Furthermore the
> correct solution is obvious. But I made up the example for
> illustration only.
> 
> ----------------------------Try
> 1--------------------------------------------
> 
> q = {{x[1], y[1]}, {x[2], y[2]}};
> FindRoot[{q[[1]] + q[[2]] Sqrt[q[[2]].q[[2]]] == {0, 0}, 
>     q[[1]] + q[[2]] == {0, 0}}, {q[[1]], {0, 0}}, {q[[2]], {0, 0}}]
> 
> This results in the error message :
> 
> FindRoot::"fddis": Start specification {q[[1]],{0,0}} does not contain
> distinct
> starting values.
> 
> 
> ----------------------------Try
> 2---------------------------------------------
> 
> FindRoot[{q[[1]] + q[[2]] Sqrt[q[[2]].q[[2]]] == {0, 0}, 
>     q[[1]] + q[[2]] == {0, 0}}, {x[1], 0}, {x[2], 0}, {y[1], 0},
> {y[2], 0}]
> 
> This results in the error message :
> 
> FindRoot::"frnum": "Function {0.,0.},{0.,0.}} is not a length 4 list
> of numbers at {x[1],x[2],y[1],y[2]} = {0., 0., 0., 0.}
> 
> Questions 
> 
> 1) How do I fix these two methods ? 

For the second, you can ...

o Make sure the first argument is evaluated (use Evaluate[])
o Get rid of the Equal (==)
o Flatten the vectors.

In[1]:=
q={{x[1],y[1]},{x[2],y[2]}};
FindRoot[Evaluate[
     Flatten[{q[[1]]+q[[2]] Sqrt[q[[2]].q[[2]]],q[[1]]+q[[2]]}]],{x[1],
     0},{x[2],0},{y[1],0},{y[2],0}]

Out[2]=
{x[1] -> 0., x[2] -> 0., y[1] -> 0., y[2] -> 0.}

For the first, you will have to wait until a future version of Mathematica (this 
works in a development version now as shown below) which will support vector 
variables.  It will still not support variables with head Part (like q[[1]]), so 
you can do

FindRoot[{q1 + q2 Sqrt[q2.q2], q1 + q2},{q1,{0,0}},{q2,{0,0}}]

which returns

In[1]:=
FindRoot[{q1 + q2 Sqrt[q2.q2], q1 + q2},{q1,{0,0}},{q2,{0,0}}]


Out[4]=
{q1 -> {0., 0.}, q2 -> {0., 0.}}From In[4]:=

Note that the Evaluate[] will no longer be necessary

> 2) What do the error messages mean ?

FindRoot::"fddis": means FindRoot is looking for numbers as starting values.
FindRoot has a syntax which accepts two starting values for using derivative
free methods.  From the input you gave, it cannot resolve what you are trying to do.


FindRoot::"frnum": If FindRoot cannot resolve a list of equalities, it looks for
a list of something which evaluates to numbers when the variables take on 
numerical values.



> 
> Please keep in mind that this example is made up and trivial to solve
> without Mathematica. It is being used for illustration purpose only.
> 
> Thanks
> 



  • Prev by Date: Re: How to simulate the Doppler Effect ?
  • Next by Date: PlotLabel
  • Previous by thread: FindRoot and vector equations
  • Next by thread: RE (long): ... RE: rectangle intersection