Re: Q about Nonlinear Simul. Eq
- To: mathgroup at smc.vnet.net
- Subject: [mg3728] Re: [mg3716] Q about Nonlinear Simul. Eq
- From: brucec (Bruce Carpenter)
- Date: Thu, 11 Apr 1996 02:52:38 -0400
- Sender: owner-wri-mathgroup at wolfram.com
>Hello, > >I'm a newbie in this group. I have a question about solving nonlinear >simultaneous equation. Please forgive me if my question is trivial. > >Is there any built-in function solving nonlinear simultaneous equations >in Mathematica? Or do I have to make a subroutine or a function to do >that? > >Currently I'm using Mathematica v. 2.2.3 under UNIX. > > >The following shows a small example for your reference: > >I tried to estimate x and y from this equation: >********************************************************************* >NSolve[{ > x - 4 (Exp[-1 - 2x] / (Exp[-1 - 2x] + Exp[-2 - y])) == 0, > y - 4 (Exp[-2 - y] / (Exp[-1 - 2x] + Exp[-2 - y])) == 0, > x + y == 4 > }, > {x, y}] >********************************************************************* > >After hitting shift+enter, what I get is the following message and the >output: > >********************************************************************* >Solve::tdep: > The equations appear to involve transcendental functions of > the variables in an essentially non-algebraic way. > >Out[1]= > -1 - 2 x > -4 E >NSolve[{------------------- + x == 0, > -1 - 2 x -2 - y > E + E > > -2 - y > -4 E > ------------------- + y == 0, x + y == 4}, {x, y}] > -1 - 2 x -2 - y > E + E >******************************************************************** > >Thank you for your help in advance. > > >J.C. Hi Jinchul, NSolve is a general way to find numerical solutions to polynomial equations. For arbitrary equations, there is FindRoot. In[119]:= ??FindRoot FindRoot[lhs == rhs, {x, x0}] searches for a numerical solution to the equation lhs == rhs, starting with x == x0. Attributes[FindRoot] = {HoldAll, Protected} Options[FindRoot] = {AccuracyGoal -> Automatic, Compiled -> True, DampingFactor -> 1, Jacobian -> Automatic, MaxIterations -> 15, WorkingPrecision -> 16} For your set of equations: In[120]:= soln = FindRoot[{x - 4 (Exp[-1 - 2 x] / (Exp[-1 - 2 x] + Exp[-2 - y])) == 0, x + y - 4 == 0}, {x, 1.7}, {y, 2.2}] Out[120]= {x -> 1.75033, y -> 2.24967} The three equations you gave overdetermine the system, so I just used two of them. Then I checked the solution against all three equations. In[121]:= {x - 4 (Exp[-1 - 2x] / (Exp[-1 - 2x] + Exp[-2 - y])), y - 4 (Exp[-2 - y] / (Exp[-1 - 2x] + Exp[-2 - y])), x + y - 4 } /. soln Out[121]= -16 {0., 4.44089 10 , 0.} Best Regards, Bruce Carpenter ----------------------- Bruce Carpenter Courseware Coordinator phone: (217) 398-0700 Wolfram Research, Inc. fax: (217) 398-0747 100 Trade Centre Drive email: brucec at wolfram.com Champaign, IL 61820 web: http://www.wolfram.com ==== [MESSAGE SEPARATOR] ====