0
|
8118 Views
|
11 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Solve a system of 8 equations with 8 variables using NSolve?

Posted 8 years ago
 I am working in a system of 8 equations and am trying to solve for 8 variables. I ran NSolve[{equations},{vars},Reals], and it just spat out my equations back at me. Am I missing something or using this routine incorrectly? Any help would be appreciated. Pasting my code below Clear["Global'*"]; NSolve[{( 4 rin)/((kmn + 4) ((.25 wcr)^senc + 1) ((.25 wfr)^senf + 1)) - 36.923 == 0, (7 rin)/((kmn + 7) ((.5 wcr)^senc + 1) ((.5 wfr)^senf + 1)) - 63.077 == 0, (16 rin)/((kmn + 16) ((.75 wcr)^senc + 1) ((.75 wfr)^senf + 1)) - 147.962 == 0, (46 rin)/((kmn + 46) (wcr^senc + 1) (wfr^senf + 1)) - 270.769 == 0, (4 rin)/((kmn + 4) ((.25 dcr)^senc + 1) ((.25 dfr)^senf + 1)) - 33.323 == 0, (7 rin)/((kmn + 7) ((.5 dcr)^senc + 1) ((.5 dfr)^senf + 1)) - 83.446 == 0, (16 rin)/((kmn + 16) ((.75 dcr)^senc + 1) ((.75 dfr)^senf + 1)) - 498.46 == 0, (46 rin)/((kmn + 46) (dcr^senc + 1) (dfr^senf + 1)) - 1206.154 == 0}, {rin, kmn, wcr, senc, wfr, senf, dcr, dfr},Reals] 
11 Replies
Sort By:
Posted 8 years ago
 Perhaps there is no solution in the reals.Could you use NMinimize and Norm or something similar and test this?
Posted 8 years ago
 You may use the function FindMinimum[] to find a local solution of the sum of squares of the right parts of the equations: In[110]:= Remove["Global*"] f[rin_, kmn_, wcr_, senc_, wfr_, senf_, dcr_, dfr_] := (-33.323 + ( 4 rin)/((1 + 0.25^senc dcr^senc) (1 + 0.25^senf dfr^senf) (4 + kmn)))^2 + (-83.446 + ( 7 rin)/((1 + 0.5^senc dcr^senc) (1 + 0.5^senf dfr^senf) (7 + kmn)))^2 + (-498.46 + ( 16 rin)/((1 + 0.75^senc dcr^senc) (1 + 0.75^senf dfr^senf) (16 + kmn)))^2 + (-1206.154 + ( 46 rin)/((1 + dcr^senc) (1 + dfr^senf) (46 + kmn)))^2 + (-270.769 + ( 46 rin)/((46 + kmn) (1 + wcr^senc) (1 + wfr^ senf)))^2 + (-36.923 + ( 4 rin)/((4 + kmn) (1 + 0.25^senc wcr^senc) (1 + 0.25^senf wfr^senf)))^2 + (-63.077 + ( 7 rin)/((7 + kmn) (1 + 0.5^senc wcr^senc) (1 + 0.5^senf wfr^senf)))^2 + (-147.962 + ( 16 rin)/((16 + kmn) (1 + 0.75^senc wcr^senc) (1 + 0.75^senf wfr^senf)))^2 FindMinimum[ f[rin, kmn, wcr, senc, wfr, senf, dcr, dfr], {{rin, 0}, {kmn, 0}, {wcr, 0}, {senc, 1}, {wfr, 0}, {senf, 1}, {dcr, 0}, {dfr, 0}}] During evaluation of In[110]:= FindMinimum::nrlnum: The function value {58.7515 +1.24773*10^-6 I,64.166 +5.73835*10^-6 I,-302.257+0.0000286716 I,-71.1665+0.000314776 I,-<<19>>+<<22>> I,21.2778 +1.47581*10^-7 I,-11.9125+3.24322*10^-7 I,-126.799+5.43301*10^-7 I} is not a list of real numbers with dimensions {8} at {rin,kmn,wcr,senc,wfr,senf,dcr,dfr} = {43.8887,-0.325894,-0.164521,1.,-0.164521,1.,-0.804443,-0.804443}. Out[112]= {103366., {rin -> 43.8887, kmn -> -0.325894, wcr -> -0.164521, senc -> 1., wfr -> -0.164521, senf -> 1., dcr -> -0.804443, dfr -> -0.804443}} If the minimal value would be $0$, it meant the solution of the initial system of equations, As the found minimal values is not $0$, it means only that the function FindMinimum[] did not find the solution of the system of equations. We can only assume that the system doesn't have the solution.Sure, you may select other initial point to search for other local solutions.
Posted 8 years ago
 Ok. I can take this and check out some ideas. Bill, I'm a little lost as to what you mean with the NMinimize and Norm comment, do you have an example I could work with?
Posted 8 years ago
 Valeriu, I have updated my equations slightly and tried to use the code you gave me but it is kicking out an error, and I can't seem to see where the problem is right off, but when it is convenient I would appreciate your help Clear["Global'*"]; f[rin_, kmn_, wfr1_, senf_, wfr2_, dfr1_, dfr2_, dfr3_] := (-33.323 + (4 rin)/((kmn + 4) ((.5 dfr1)^senf + 1)))^2 + (-83.446 + (7 rin)/((kmn + 7) ((dfr1)^senf + 1)))^2 + (-498.46 + (16 rin)/((kmn + 16) ((dfr2)^senf + 1)))^2 + (-1206.154 + (46 rin)/((kmn + 46) (dfr3^senf + 1)))^2 + (-270.769 + (46 rin)/((kmn + 46) (wfr2^senf + 1)))^2 + (-36.923 + (4 rin)/((kmn + 4) ((.5 wfr1)^senf + 1)))^2 + (-63.077 + (7 rin)/((kmn + 7) ((wfr1)^senf + 1)))^2 + (-147.962 + (16 rin)/((kmn + 16) ((.5 wfr2)^ senf + 1)))^2 FindMinimum[ f[rin, kmn, wfr1, senf, wfr2, dfr1, drf2, dfr3], {{rin, 0}, {kmn, 0}, {wfr1, 0}, {senf, 1}, {wfr2, 0}, {dfr1, 0}, {dfr2, 0}, {dfr3, 0}}] 
Posted 8 years ago
 I had posted a reply but it didn't look like it went to you. Posting this so it will notify you
Posted 8 years ago
 Josh, I have used also the function Minimize[] by fixing 6 or 7 arguments and minimizing the function f[] on the rest of variables and succeed to find the following local solution: In[1]:= f[6.171439493048681*^14, 2.3506806096409836*^13, \ 0.16717122698568856, 1.0555557671120848, 2.9971, 1.3111, 0, 0] Out[1]= 20784.9 
Posted 8 years ago
 So you set up a Minimize[] instead of the FindMinimum in the code? Sorry I'm still learning the various ropes of mathematica
Posted 8 years ago
 Consider Solve[{3 x^2 + 4 == 0, 2 y - 2 == 0}, {x, y}, Reals] which just gives you {}. Did it not find a solution? Is there no solution? Is there just an error in the code? You might not know. (For such a simple problem you can look at it and know, but for your much more complicated system you probably can't look at it and know if there is a solution or not) Solve can only give you a solution or {}, or an error message if you really mess up the syntax.Consider instead NMinimize[Norm[3 x^2 + 4] + Norm[2 y - 2], {x, y}] This might tell you more. It can tell you if it found something very close to a zero minimum. Or it can tell you the smallest value that it found and where it found that.Using Norm avoids things like a positive first equation plus a negative second equation giving you a zero minimum. And it avoids the issue of complex numbers appearing in complicated equations. You could just square things, but what happens if 3-5*I appears in your equation, what is the square of that?If it gives you something very close to zero then that might represent a solution. But if it gives you a non zero minimum then you might want to think there is no solution to your two equations. There is always the issue of local minimum that you have to think about and that there might be a zero or almost zero minimum that is just very very hard to find.My hints were intended to get you to think of all these things yourself. Does this now give you some ideas how to proceed?
Posted 8 years ago
 I have fixed some variables and used Minimize[] for the rest of variables... Unfortunately, this is all I can do for the moment!
Posted 8 years ago
 Indeed this all has given me some good ideas. I appreciate your help and suggestions Bill. Thank you
Posted 8 years ago
 Apropos, Josh! You have done a mistake in writing argument of the function f[] in FindMinimum[]. The last but one argument must be dfr2 not drf2.