# Solving System of six Non-Linear Equations in Six Unknowns

I've been trying to solve the following system of equations using NSolve and the code has been running for close to 24 hours already. Is this normal? Is there a quicker way to solve these equations? Thanks:

NSolve[{((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m -
1)) + (Log[x + y + z + k + l + m - 1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k + l + m + 161 - 1)) - (Log[x + y + z + k + l + m + 161 - 1]) + ((33 + x + 180 - 0.5)/(33 + x + 180 - 1)) + (Log[33 + x + 180 - 1]) - ((33 + x - 0.5)/(33 + x - 1)) -
Log[33 + x - 1] == 0,  ((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m - 1)) + (Log[x + y + z + k + l + m - 1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k + l + m + 161 - 1)) - (Log[x + y + z + k + l + m + 161 - 1]) + ((65 + y + 198 - 0.5)/(65 + y + 198 - 1)) + (Log[65 + y + 198 - 1]) - ((65 + y - 0.5)/(65 + y - 1)) - Log[65 + y - 1] == 0,  ((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m - 1)) + (Log[x + y + z + k + l + m - 1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k + l + m + 161 - 1)) - (Log[x + y + z + k + l + m + 161 - 1]) + ((140 + z + 133 - 0.5)/(140 + z + 133 - 1)) + (Log[140 + z + 133 - 1]) - ((140 + z - 0.5)/(140 + z - 1)) - Log[140 + z - 1] == 0,  ((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m - 1)) + (Log[x + y + z + k + l + m - 1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k + l + m + 161 - 1)) - (Log[x + y + z + k + l + m + 161 - 1]) + ((195 + k + 139 - 0.5)/(195 + k + 139 - 1)) + (Log[195 + k + 139 - 1]) - ((195 + k - 0.5)/(195 + k - 1)) - Log[195 + k - 1] == 0,  ((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m - 1)) + (Log[x + y + z + k + l + m -1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k + l +m + 161 - 1)) - (Log[x + y + z + k + l + m + 161 - 1]) + ((251 + l + 171 - 0.5)/(251 + l + 171 - 1)) + (Log[251 + l + 171 - 1]) - ((251 + l - 0.5)/(251 + l - 1)) - Log[251 + l - 1] == 0,  ((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m - 1)) + (Log[x + y + z + k + l + m - 1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k + l + m + 161 - 1)) - (Log[x + y + z + k + l + m + 161 - 1]) + ((281 + m + 144 - 0.5)/(281 + m + 144 - 1)) + (Log[281 + m + 144 - 1]) - ((281 + m - 0.5)/(281 + m - 1)) - Log[281 + m - 1] == 0}, {x, y, z, k, l, m}]

• sltn = FindInstance[ Simplify[Factor[Rationalize[eqn, 0]]], {x, y, z, k, l, m}] returns an answer quickly. eqn is what you have inside {} in the NSolve command
– bmf
Apr 24 at 17:38
• In a couple of seconds NMinimize of the sum of the squares of your equations along with x>0,y>0,z>0,k>0,l>0,m>0 finds a sum of squares close to zero. The reason for adding the positive constraints is to avoid negative values being given to Log and avoiding complex numbers. That hints the solution involves z==0, k==0, l==0, m==0
– Bill
Apr 24 at 18:11
• I just ran the code bmf posted above and it gave an answer where x,y,z are positive and k,l,m are negative. How do I make the code only give me positive answers, i.e how do I include the constraints Bill posted above in the code? Thanks. Apr 24 at 18:22

I suspect your system does not have a positive real solution. Let eqs be your equation list, and introduce dummy variable q.

eqs2 = eqs /. {x + y + z + k + l + m -> q + 1};
vars = {x, y, z, k, l, m, q};
FindInstance[Join[eqs2, Evaluate@Thread[vars >= 0]], vars, Reals]


Note q is nowhere near x + y + z + k + l + m - 1. This is only suggestive, but I look around a bit.

• I included your code @Alan above but when I run it I get the error: FindInstance::naqs: Join[eqs,{x>=0,y>=0,z>=0,k>=0,l>=0,m>=0,q>=0}] is not a quantified system of equations and inequalities. Thanks. Apr 24 at 19:16
• @Thando You need to set eqs to your equation list.
– Alan
Apr 24 at 20:30
• Thanks @Alan, I ran it again and it works now. I got all positive answers. What I'm not sure about is the q, instead of getting answers for six variables as intended I got answers for seven variables including q. How does the introduction of q change the original system of equations? What's the meaning of q? Thanks, Apr 24 at 20:42

You only get exact solution of equations with all variables positive for all variables going to Infinity.

But as you mentioned yourself, there is solution with some variables negative.

eqs = {((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m -
1)) + (Log[
x + y + z + k + l + m -
1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k +
l + m + 161 - 1)) - (Log[
x + y + z + k + l + m + 161 -
1]) + ((33 + x + 180 - 0.5)/(33 + x + 180 - 1)) + (Log[
33 + x + 180 - 1]) - ((33 + x - 0.5)/(33 + x - 1)) -
Log[33 + x - 1] ==
0, ((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m -
1)) + (Log[
x + y + z + k + l + m -
1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k +
l + m + 161 - 1)) - (Log[
x + y + z + k + l + m + 161 -
1]) + ((65 + y + 198 - 0.5)/(65 + y + 198 - 1)) + (Log[
65 + y + 198 - 1]) - ((65 + y - 0.5)/(65 + y - 1)) -
Log[65 + y - 1] ==
0, ((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m -
1)) + (Log[
x + y + z + k + l + m -
1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k +
l + m + 161 - 1)) - (Log[
x + y + z + k + l + m + 161 -
1]) + ((140 + z + 133 - 0.5)/(140 + z + 133 - 1)) + (Log[
140 + z + 133 - 1]) - ((140 + z - 0.5)/(140 + z - 1)) -
Log[140 + z - 1] ==
0, ((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m -
1)) + (Log[
x + y + z + k + l + m -
1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k +
l + m + 161 - 1)) - (Log[
x + y + z + k + l + m + 161 -
1]) + ((195 + k + 139 - 0.5)/(195 + k + 139 - 1)) + (Log[
195 + k + 139 - 1]) - ((195 + k - 0.5)/(195 + k - 1)) -
Log[195 + k - 1] ==
0, ((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m -
1)) + (Log[
x + y + z + k + l + m -
1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k +
l + m + 161 - 1)) - (Log[
x + y + z + k + l + m + 161 -
1]) + ((251 + l + 171 - 0.5)/(251 + l + 171 - 1)) + (Log[
251 + l + 171 - 1]) - ((251 + l - 0.5)/(251 + l - 1)) -
Log[251 + l - 1] ==
0, ((x + y + z + k + l + m - 0.5)/(x + y + z + k + l + m -
1)) + (Log[
x + y + z + k + l + m -
1]) - ((x + y + z + k + l + m + 161 - 0.5)/(x + y + z + k +
l + m + 161 - 1)) - (Log[
x + y + z + k + l + m + 161 -
1]) + ((281 + m + 144 - 0.5)/(281 + m + 144 - 1)) + (Log[
281 + m + 144 - 1]) - ((281 + m - 0.5)/(281 + m - 1)) -
Log[281 + m - 1] == 0};


Regard left side of equations and rationalize to be able to work with higher working precision.

(feqs = (Subtract @@@ eqs) // Rationalize[#, 0] &) // TableForm

vars = {x, y, z, k, l, m};


Minimization of squared equations shows, you get the higher solutions for variables, the higher working precision you use. Indicates exact solution for variables at infinity. And in fact Limit proofs it.

nmin1 = NMinimize[{feqs.feqs, Thread[0 < {x, y, z, k, l, m}]}, vars,
Method -> "SimulatedAnnealing"]

(*  {3.92628*10^-13, {x -> 6.56375*10^8, y -> 5.58981*10^8,
z -> 4.85401*10^8, k -> 4.88616*10^8, l -> 4.926*10^8,
m -> 4.93386*10^8}}    *)

feqs /. nmin1[[2]]

(*   {2.23531*10^-7, 3.03513*10^-7, 2.23297*10^-7, 2.33774*10^-7,
2.96434*10^-7, 2.41158*10^-7}   *)

nmin2 = NMinimize[{feqs.feqs, Thread[0 < {x, y, z, k, l, m}]}, vars,
WorkingPrecision -> 60, Method -> "SimulatedAnnealing"]

(*   {2.65602293774914755086447992600475808799651529792969070656554*10^-67,\
{x -> 2.15092592056215278724904161136197120016172875657991575851007*\
10^37, y ->
8.10817593517395163050508314777294099547972238199932492492066*10^\
35, z -> 1.\
22434659707631587959463439108626860556815836737826785019198*10^36,
k -> 1.10980547270990469626710509501226342706782028540968187956545*\
10^36, l ->
4.10040594927114096017979594754827559682223940174038041446560*10^\
35, m -> 1.\
10473708166808079291968485040433376400926979893447715591471*10^36}}   *)

feqs /. nmin2[[2]]

(*   {2.2161729548042747987666*10^-36, 2.380456411126400378256152*10^-34,
1.024770543178320135446274*10^-34, 1.190948586800392334626972*10^-34,
4.108795634751322288169653*10^-34,
1.241954403044963022168268*10^-34}   *)

Limit[feqs[[1]], x -> Infinity]

(*   0   *)

MapThread[Limit[#1, #2 -> Infinity] & , {feqs, vars}]

(*   {0, 0, 0, 0, 0, 0}   *)