Message Boards Message Boards

0
|
7335 Views
|
12 Replies
|
0 Total Likes
View groups...
Share
Share this post:

solve equation system for five order

Posted 10 years ago

Good night everybody, I need to solve the system:

NSolve[       {  7.61 == -((26.3 + 7.6*Rs)/Rp) - 1*(-1 + E^((38.91* (26.3 + 7.61* Rs))/A)) *Io + Ip,
           8.21 == -((8.21* Rs)/Rp) - 1*(-1 + E^((319.51* Rs)/A)) *Io + Ip, 
           0 == -(32.9/Rp) - 1*(-1 + E^(1280.38/(A))) *Io + Ip,
           6.62 == -((6.62* Rs)/Rp) - 1*(-1 + E^((239.92*Rs)/A)) *Io + Ip,
           0 == -(29.9/Rp) - 1*(-1 + E^(1083.66/(A))) *Io + Ip},
            {Io, Ip, A, Rs, Rp}]

But I don't know if the NSolve command is appropriate. if someone have idea for solve this, help me please

Thank you!

12 Replies

This variant works reasonably well. We sum absolute values of discrepancies (instead of squares).

eqs = {7.61 == 
    0. - (26.3 + 7.6*Rs)/Rp - 
     1. (-1 + E^((38.91741123737115*(26.3 + 7.61*Rs))/A)) Subscript[i,
        o] + Subscript[i, ph], 
   8.21 == 0. - (8.21*Rs)/Rp - 
     1. (-1 + E^((319.51194625881715*Rs)/A)) Subscript[i, o] + 
     Subscript[i, ph], 
   0 == 0. - 32.9/Rp - 
     1. (-1 + E^(1280.3828297095108/A)) Subscript[i, o] + 
     Subscript[i, ph], 
   6.62 == 0. - (6.62*Rs)/Rp - 
     1. (-1 + E^((239.92927434638457*Rs)/A)) Subscript[i, o] + 
     Subscript[i, ph], 
   0 == 0. - 29.9/Rp - 
     1. (-1 + E^(1083.668474766903/A)) Subscript[i, o] + 
     Subscript[i, ph]};
exprs = Apply[Subtract, eqs, {1}];
obj = Total[Abs[exprs]];
vars = {Rp, Rs, Subscript[i, o], Subscript[i, ph], A};

One can try various methods in NMinimize. I had best results from simulated annealing, though possibly that was just luck.

SeedRandom[1111]; Quiet[
 res = Table[
   NMinimize[obj, vars, 
    Method -> {"SimulatedAnnealing", 
      "RandomSeed" -> RandomInteger[100000]}], {8}]]

(* Out[128]= {{1.87674549158, {Rp -> -22.1775022222, Rs -> 27.1223664498,
    Subscript[i, o] -> -1.27242985435, 
   Subscript[i, ph] -> -0.211055515253, 
   A -> -0.0309130227249}}, {1.64764584763, {Rp -> -36.2638152639, 
   Rs -> 42.3746667989, Subscript[i, o] -> -1.06207524175, 
   Subscript[i, ph] -> -0.053467535256, 
   A -> -1.5217022262}}, {0.019707815217, {Rp -> -1107.10143767, 
   Rs -> 1110.76425648, Subscript[i, o] -> 0.806310397178, 
   Subscript[i, ph] -> -0.83347298941, 
   A -> -0.0264490342706}}, {0.736993699664, {Rp -> -45.9270205782, 
   Rs -> 49.3700088231, Subscript[i, o] -> 0.348644661474, 
   Subscript[i, ph] -> -0.999677531674, 
   A -> -0.462683666199}}, {0.137667678614, {Rp -> -1453.74805012, 
   Rs -> 1469.63492588, Subscript[i, o] -> -38.3974516083, 
   Subscript[i, ph] -> 38.3251067397, 
   A -> -0.368567703104}}, {1.12405053251, {Rp -> -29.1065949187, 
   Rs -> 32.7292298606, Subscript[i, o] -> -2.26521557848, 
   Subscript[i, ph] -> 1.23795697332, 
   A -> -1.34684133875}}, {0.0936124366274, {Rp -> -559.623069958, 
   Rs -> 565.599281418, Subscript[i, o] -> -3.10557765226, 
   Subscript[i, ph] -> 3.03488269939, 
   A -> -2.72662194692}}, {1.43175063852, {Rp -> -23.0445680163, 
   Rs -> 27.0491806745, Subscript[i, o] -> -3.23518621627, 
   Subscript[i, ph] -> 1.80847818916, A -> -1.44644488489}}} *)

The third has a small residual so we'll check how close we come with it.

exprs /. {Rp -> -1107.1014376711053`, 
  Rs -> 1110.7642564780667`, Subscript[i, o] -> 0.8063103971775648`, 
  Subscript[i, ph] -> -0.833472989409748`, A -> -0.026449034270631236`}

(* Out[130]= {-0.0117375546656, 
 2.2635415764*10^-9, -0.0025546485558, 0.00526047949255, \
0.000155130239452} *)

An alternative is to use a sum of squares and give NMinimize some nondefault settings.

obj = exprs.exprs;

SeedRandom[1111]; Quiet[
 res = Table[
   NMinimize[obj, vars, 
    Method -> {"RandomSearch", 
      "RandomSeed" -> RandomInteger[100000]}], {8}]]

(* Out[150]= {{3.53513331148*10^-6, {Rp -> -2822.92221197, 
   Rs -> 2827.13076594, Subscript[i, o] -> -0.0332358721578, 
   Subscript[i, ph] -> 0.0222353109126, 
   A -> -31.9630925697}}, {6.24332180567*10^-7, {Rp -> -2700.49545384,
    Rs -> 2705.67999858, Subscript[i, o] -> 0.000018778654236, 
   Subscript[i, ph] -> -0.0116263048577, 
   A -> 160412.601173}}, {3.53513331148*10^-6, {Rp -> -2822.92221197, 
   Rs -> 2827.13076594, Subscript[i, o] -> -0.512019293981, 
   Subscript[i, ph] -> 0.501018732736, 
   A -> -0.00380045704701}}, {3.53513331148*10^-6, {Rp -> \
-2822.92221197, Rs -> 2827.13076594, 
   Subscript[i, o] -> 0.353615439225, 
   Subscript[i, ph] -> -0.36461600047, 
   A -> -0.689503356585}}, {3.58492039403*10^-6, {Rp -> \
-2905.05796609, Rs -> 2909.30416484, Subscript[i, o] -> -38.346593732,
    Subscript[i, ph] -> 38.3359024824, 
   A -> -8.35575763632}}, {3.53513331148*10^-6, {Rp -> -2822.92221197,
    Rs -> 2827.13076594, Subscript[i, o] -> -0.165396243166, 
   Subscript[i, ph] -> 0.154395681921, 
   A -> -0.648193065037}}, {3.53513331148*10^-6, {Rp -> \
-2822.92221197, Rs -> 2827.13076594, 
   Subscript[i, o] -> -0.01209512964, 
   Subscript[i, ph] -> 0.00109456839478, 
   A -> -1.01228544162}}, {3.53513331148*10^-6, {Rp -> -2822.92221197,
    Rs -> 2827.13076594, Subscript[i, o] -> -2.27722923527, 
   Subscript[i, ph] -> 2.26622867403, A -> -1.20741804005}}} *)

We check the quality of the best of these.

exprs /. {Rp -> -2700.4954538433844`, 
  Rs -> 2705.6799985799325`, 
  Subscript[i, o] -> 0.000018778654235991685`, 
  Subscript[i, ph] -> -0.01162630485766281`, A -> 160412.60117315938`}

(* Out[149]= {0.0000695635876515, -0.0000413467732426, \
-0.000556494251506, -0.0000273792092713, 0.000554389807918} *)

So now our residuals are all under 1/1000.

I need to look into the memory allocation failure when using a sum of squares wit h default method.

POSTED BY: Daniel Lichtblau

Thank you very much, with your help the answer is successful

Tried that and got a SystemException[MemoryAllocationFailure...]. Perhaps the problem is singular?

POSTED BY: Frank Kampas

Could alternatively subtract lhs from rhs of each equation, square, and sum those as an objective function for an unconstrained optimization (maybe you also tried that though).

POSTED BY: Daniel Lichtblau
In[21]:= NMinimize[{0, 
  7.61 == 0. - (26.3 + 7.6*Rs)/Rp - 
    1. (-1 + E^((38.91741123737115* (26.3 + 7.61* Rs))/A)) Subscript[
     i, o] + Subscript[i, ph],
     8.21 == 
   0. - (8.21* Rs)/Rp - 
    1. (-1 + E^((319.51194625881715* Rs)/A)) Subscript[i, o] + 
    Subscript[i, ph], 
     0 == 0. - 32.9/Rp - 
    1. (-1 + E^(1280.3828297095108/A)) Subscript[i, o] + Subscript[i, 
    ph],
     6.62 == 
   0. - (6.62* Rs)/Rp - 
    1. (-1 + E^((239.92927434638457 *Rs)/A)) Subscript[i, o] + 
    Subscript[i, ph],
     0 == 0. - 29.9/Rp - 
    1. (-1 + E^(1083.668474766903/A)) Subscript[i, o] + Subscript[i, 
    ph]},
       {Subscript[i, ph], Subscript[i, o], A, Rs, Rp}]

During evaluation of In[21]:= NMinimize::nosat: Obtained solution does not satisfy the following constraints within Tolerance -> 0.001`: {0. +29.9/Rp+1. (-1+E^(1083.67/A)) Subscript[i, o]-Subscript[i, ph]==0,0. +32.9/Rp+1. (-1+E^(1280.38/A)) Subscript[i, o]-Subscript[i, ph]==0,6.62 +<<4>>==0,8.21 +(8.21 Rs)/Rp+1. (-1+E^(<<1>>/A)) Subscript[i, o]-Subscript[i, ph]==0,7.61 +(26.3 +7.6 Rs)/Rp+1. (-1+E^((38.9174 (<<5>> +<<1>>))/A)) Subscript[i, o]-Subscript[i, ph]==0}. >>

Out[21]= {0., {Subscript[i, ph] -> 1.42325, 
  Subscript[i, o] -> 36.4052, A -> -3.62571, Rs -> 0.00234389, 
  Rp -> 0.841729}}
POSTED BY: Frank Kampas

I'm, I don't understand, how did you apply to NMinimize Command? "giving it 0 as an objective function, along with the constraints. " Can you tell me?

I reran NMinimize, giving it 0 as an objective function, along with the constraints. It returned an answer, but with a warning message that the obtained solution did not satisfy the constraints within tolerance. The answer obtained was

{0., {Subscript[i, ph] -> 1.42325, Subscript[i, o] -> 36.4052, 
  A -> -3.62571, Rs -> 0.00234389, Rp -> 0.841729}}

Those values might serve as starting values for FindRoot.

POSTED BY: Frank Kampas

I applied the NSolve, FindRoots, FindMinimum commands and the answer isn't solve the equations.

I don't know if you see the file, but I think that Mathematica have to command for true answer

This is the file, can you help me?

Attachments:

Sometimes I get better results, at least for real valued roots, by taking a sum of squares and invoking FindMinimum or NMinimize. That latter is especially helpful when I do not have a good idea for initial values.

POSTED BY: Daniel Lichtblau

I worked with FindRoot too, but the answer was not validate. I have problem when work with FindRoot because it need initials values

Probably you will need FindRoot instead. The input is a mix of polynomial and exponential terms and NSolve really is not equipped to handle that latter.

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract