MathGroup Archive 2011

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

Search the Archive

Re: non linear system with 8 equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117197] Re: non linear system with 8 equations
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Fri, 11 Mar 2011 04:33:28 -0500 (EST)

wiso wrote:
> I've a non linear system with 8 equation:
> 
> solution = Solve[{n == ng + nn,
>      na == eag ng + ean nn,
>     nb == ebg ng + ebn nn,
>     nc == ecg ng + ecn nn,
>     nab == kabg eag ebg ng + kabn ean ebn nn,
>     nac == kacg eag ecg ng + kacn ean ecn nn,
>     nbc == kbcg ebg ecg ng + kbcn ebn ecn nn,
>     nabc == kabcg eag ebg ecg ng + kabcn ean ebn ecn nn }, {ng, nn,
>     eag, ebg, ecg, ean, ebn, ecn}];
> 
> my pc is cogitating since more than one hour. Is there some method to
> speed it up? All variables are real, n* are positive integer, e* are
> real 0<e*<1. k* are known parameters

I doubt Solve will have any chance with this. It would need to compute 
some flavor of GroebnerBasis, and that seems to be a difficult 
undertaking for this system.

If you provide explicit numeric values for those parameters then NSolve 
will handle it. Below is some code for this. It takes the polynomials, 
variables of interest, parameter substitutions, and constraints entered 
as a list.

In[160]:=
constrainedSolutions[polys_, vars_, paramsubs_, constraints_] :=
  Module[
   {solns},
   solns = NSolve[polys /. paramsubs, vars];
   Pick[solns, Quiet[And @@@ Release[constraints /. solns]]
    ]]

Here is your example. I changed the constraints so as to find parameter 
substitutions that might yield a few valid solutions. I show one such 
run below.

In[161]:=
eqns = {n == ng + nn, na == eag ng + ean nn, nb == ebg ng + ebn nn,
    nc == ecg ng + ecn nn, nab == kabg eag ebg ng + kabn ean ebn nn,
    nac == kacg eag ecg ng + kacn ean ecn nn,
    nbc == kbcg ebg ecg ng + kbcn ebn ecn nn,
    nabc == kabcg eag ebg ecg ng + kabcn ean ebn ecn nn};
polys = Apply[Subtract, eqns, 1];
vars = {ng, nn, eag, ebg, ecg, ean, ebn, ecn};
params = Complement[Variables[polys], vars];
paramsubs = Thread[params -> RandomReal[{-10, 10}, Length[params]]];
SeedRandom[11111];
constraints =
   Flatten[{Map[Hold[Head[#] === Real] && # >= 0 &, {ng, nn}],
     Map[Hold[Head[#] === Real] && -100 <= # <= 100 &, {eag, ebg, ecg,
       ean, ebn, ecn}]}];

In[168]:= constrainedSolutions[polys, vars, paramsubs, constraints]

Out[168]= {{ng -> 7.30836, nn -> 0.254874, eag -> 0.186697,
   ebg -> -0.90457, ecg -> -0.0648619, ean -> 2.44744, ebn -> 0.726247,
    ecn -> -2.57797}, {ng -> 4.8318, nn -> 2.73144, eag -> -0.428736,
   ebg -> -1.02281, ecg -> -0.46866, ean -> 1.48632, ebn -> -0.543236,
   ecn -> 0.414936}, {ng -> 1.00957, nn -> 6.55367, eag -> -0.174131,
   ebg -> -3.37666, ecg -> -4.50395, ean -> 0.330202, ebn -> -0.460332,
    ecn -> 0.521227}}

If you know a priori that your system will have exactly one solution 
satisfying the constraints, then you might do better using FindRoot with 
appropriate initial values for the variables. But for this particular 
system of polynomials NSolve will be fast (again, provided you give 
numerical values up front for the parameters).

Daniel Lichtblau
Wolfram Research


  • Prev by Date: Re: determining boundary of a region in n-dimensional
  • Next by Date: Re: non linear system with 8 equations
  • Previous by thread: Re: non linear system with 8 equations
  • Next by thread: Re: non linear system with 8 equations