1
$\begingroup$

As I stated in this question I want to solve a series of equations while setting some rules such as q[2]->1 or q[2]->3*10^-4. However, what should I do if I want to set another rules to my input? I want absolute values of all other variables to be less than 10^-4. I tried this input:

eqns = -7.876174155966237*10^8 q[1]*q[2] - 3.089573929076111*10^11 q[1]*q[3]-1.383164420023547*10^11 q[1]*q[4]-8.69327863244762*10^10 q[1]*q[5]-5.782276395051118*10^10 q[1]*q[6]-3.882747274312769*10^10 q[1]*q[7] -2.718153431333784*10^10 q[1]*q[8] - 1.871727631370937*10^10 q[1]*q[9] - 1.160739768204187*10^10 q[1]*q[10] - 8.06637222864757*10^9 q[1]*q[11] - 5.963897903744298*10^9 q[1]*q[12] - 4.915457539792909*10^9 q[1]*q[13] == 41.572661478570835177915, 
-8.286948780105069*10^8 q[3]*q[2] + 3.089573929076111*10^11 q[1]*q[3] -3.14514257979788*10^11 q[3]*q[4] - 1.364812421413417*10^11 q[3]*q[5] -8.200749083805965*10^10 q[3]*q[6] - 5.199209763929092*10^10 q[3]*q[7] -3.48884718739484*10^10 q[3]*q[8] - 2.32869468208448*10^10 q[3]*q[9] -1.380239079268908*10^10 q[3]*q[10] - 9.323329484842843*10^9 q[3]*q[11] -6.754539699898449*10^9 q[3]*q[12] - 5.502821647682379*10^9 q[3]*q[13] == 39.090711539551680838935,
-8.668692005924783*10^8 q[4]*q[2] + 3.14514257979788*10^11 q[3]*q[4] + 1.383164420023547*10^11 q[1]*q[4] - 3.018556794730371*10^11 q[4]*q[5] - 1.251939130894869*10^11 q[4]*q[6] - 7.200708200204837*10^10 q[4]*q[7] - 4.581328545341369*10^10 q[4]*q[8] - 2.95259803140547*10^10 q[4]*q[9] - 1.660482187826396*10^10 q[4]*q[10] - 1.086049100232898*10^10 q[4]*q[11] - 7.691599943122406*10^9 q[4]*q[12] - 6.186520887032309*10^9 q[4]*q[13] == 39.71119902430646942368,
-9.097718004913528*10^8 q[5]*q[2] + 3.018556794730371*10^11 q[4]*q[5] + 1.364812421413417*10^11 q[3]*q[5] + 8.69327863244762*10^10 q[1]*q[5] - 2.662069346680555*10^11 q[5]*q[6] - 1.084567931193396*10^11 q[5]*q[7] - 6.327869929154266*10^10 q[5]*q[8] - 3.90046696238858*10^10 q[5]*q[9] - 2.0539044834737896*10^10 q[5]*q[10] - 1.291216086273309*10^10 q[5]*q[11] - 8.897680949562239*10^9 q[5]*q[12] - 7.048512495674284*10^10 q[5]*q[13] == 43.43412393283520093215,
-9.58107308865949*10^8 q[6]*q[2] + 2.662069346680555*10^11 q[5]*q[6] +1.251939130894869*10^11 q[4]*q[6] + 8.200749083805965*10^10 q[3]*q[6] + 5.782276395051118*10^10 q[1]*q[6] - 2.416484550106671*10^11 q[6]*q[7] - 1.000589953622153*10^11 q[6]*q[8] - 5.667851443992393*10^10 q[6]*q[9] - 2.71540993739268*10^10 q[6]*q[10] - 1.613848374025927*10^10 q[6]*q[11] - 1.070606507930378*10^10 q[6]*q[12] - 8.3069156585462*10^9 q[6]*q[13] == 59.676973696887311026395,
-1.023694674428333*10^9 q[7]*q[2] + 2.416484550106671*10^11 q[6]*q[7] + 1.084567931193396*10^11 q[5]*q[7] + 7.200708200204837*10^10 q[4]*q[7] + 5.199209763929092*10^10 q[3]*q[7] + 3.882747274312769*10^10 q[1]*q[7] - 2.335526899537523*10^11 q[7]*q[8] - 9.170819378390439*10^10 q[7]*q[9] - 3.868051931218125*10^10 q[7]*q[10] - 2.128903059755466*10^10 q[7]*q[11] - 1.341864327566713*10^10 q[7]*q[12] - 1.013051826593238*10^10 q[7]*q[13] == 59.676973696887311026395,
-1.09740654139634*10^9 q[8]*q[2] + 2.335526899537523*10^11 q[7]*q[8] + 1.000589953622153*10^11 q[6]*q[8] + 6.327869929154266*10^10 q[5]*q[8] + 4.581328545341369*10^10 q[4]*q[8] + 3.48884718739484*10^10 q[3]*q[8] + 2.718153431333784*10^10 q[1]*q[8] - 1.632980324637583*10^11 q[8]*q[9] - 5.906288180566143*10^10 q[8]*q[10] - 2.944094061812386*10^10 q[8]*q[11] - 1.737854910543447*10^10 q[8]*q[12] - 1.267694594748506*10^10 q[8]*q[13] == 15.429339603838925,
-1.226485374572291*10^9 q[9]*q[2] + 1.632980324637583*10^11 q[8]*q[9] + 9.170819378390439*10^10 q[7]*q[9] + 5.667851443992393*10^10 q[6]*q[9] + 3.90046696238858*10^10 q[5]*q[9] + 2.95259803140547*10^10 q[4]*q[9] + 2.32869468208448*10^10 q[3]*q[9] + 1.871727631370937*10^10 q[1]*q[9] - 1.319053049676902*10^11 q[9]*q[10] - 5.363293427524359*10^10 q[9]*q[11] - 2.756647166322137*10^10 q[9]*q[12] - 1.87253921409798*10^10 q[9]*q[13] == 30.3662534756404375,
-1.421056739280782*10^9 q[10]*q[2] + 1.319053049676902*10^11 q[9]*q[10] + 5.906288180566143*10^10 q[8]* q[10] + 3.868051931218125*10^10 q[7]*q[10] + 2.71540993739268*10^10 q[6]*q[10] + 2.0539044834737896*10^10 q[5]*q[10] + 1.660482187826396*10^10 q[4]*q[10] + 1.380239079268908*10^10 q[3]*q[10] + 1.160739768204187*10^10 q[1]*q[10] - 1.369382557754065*10^11 q[10]*q[11] - 5.811111845727664*10^10 q[10]*q[12] - 3.464461454834223*10^10 q[10]*q[13] == 29.54554392224475,
-1.649776763694766*10^9 q[11]*q[2] + 1.369382557754065*10^11 q[10]*q[11] + 5.363293427524359*10^10 q[9]*q[11] + 2.944094061812386*10^10 q[8]*q[11] + 2.128903059755466*10^10 q[7]*q[11] +1.613848374025927*10^10 q[6]*q[11] + 1.291216086273309*10^10 q[5]*q[11] + 1.086049100232898*10^10 q[4]*q[11] + 9.323329484842843*10^9 q[3]*q[11] + 8.06637222864757*10^9 q[1]*q[11] - 1.406003409468488*10^11 q[11]*q[12] - 7.363054544339372*10^10 q[11]*q[13] == 26.4268476193411375,
-1.926892257497436*10^9 q[12]*q[2] + 1.406003409468488*10^11 q[11]*q[12] + 5.811111845727664*10^10 q[10]*q[12] + 2.756647166322137*10^10 q[9]*q[12] + 1.737854910543447*10^10 q[8]*q[12] + 1.341864327566713*10^10 q[7]*q[12] + 1.070606507930378*10^10 q[6]*q[12] + 8.897680949562239*10^9 q[5]*q[12] + 7.691599943122406*10^9 q[4]*q[12] + 6.754539699898449*10^9 q[3]*q[12] +5.963897903744298*10^9 q[1]*q[12] - 1.636667034244436*10^11 q[12]*q[13] == 27.5758409940951,
-2.169244191944226*10^9 q[13]*q[2] + 1.636667034244436*10^11q[12]*q[13] + 7.363054544339372*10^10 q[11]*q[13] + 3.464461454834223*10^10 q[10]*q[13] + 1.87253921409798*10^10 q[9]*q[13] + 1.267694594748506*10^10 q[8]*q[13] + 1.013051826593238*10^10 q[7]*q[13] + 8.3069156585462*10^9 q[6]*q[13] + 7.048512495674284*10^10 q[5]*q[13] + 6.186520887032309*10^9 q[4]*q[13] + 5.502821647682379*10^9 q[3]*q[13] + 4.915457539792909*10^9 q[1]*q[13] == 27.5778412995448368
NSolve[eqns /. {{q[2] -> 3*10^-4}, {Abs[q[3]] < 10^-4}, {Abs[q[4]] < 10^-4}, {Abs[q[5]]< 10^-4}, {Abs[q[6]] < 10^-4}, {Abs[q[7]] < 10^-4}, {Abs[q[8]] < 10^-4}, {Abs[q[9]] < 10^-4}, {Abs[q[10]] < 10^-4}, {Abs[q[11]] < 10^-4}, {Abs[q[12]] < 10^-4}, {Abs[q[13]] <10^-4}}, {q[1], q[2], q[3], q[4], q[5], q[6], q[7], q[8], q[9], q[10], q[11], q[12], q[13]}, Reals]

However, it didn't work and gave me thes errors:

ReplaceAll::reps: "{Abs[q[3]]<1/10000} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.
ReplaceAll::reps: {Abs[q[4]]<1/10000} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. 
ReplaceAll::reps: {Abs[q[5]]<1/10000} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. 
General::stop: Further output of ReplaceAll::reps will be suppressed during this calculation. 
NSolve::naqs: <<1>> is not a quantified system of equations and inequalities.

What am I doing wrong?

$\endgroup$
  • $\begingroup$ NSolve supports inequalities, have a look at the documentation. $\endgroup$ – b.gates.you.know.what Dec 14 '14 at 9:32
  • $\begingroup$ @b.gatessucks In the previous question I asked(I gave link in the question) I got an answer to use NSolve and it worked for just q[2]->3*10^-4. If it is wrong, can you show me the correct input? $\endgroup$ – Starior Dec 14 '14 at 9:36
  • 2
    $\begingroup$ I would do : vars = {q[1], q[2], q[3], q[4], q[5], q[6], q[7], q[8], q[9], q[10], q[11], q[12], q[13]}; equal = {q[2] == 3*10^-4}; inequal = Abs[#] < 10^(-4) & /@ vars[[3 ;;]]; sol = NSolve[Join[eqns, equal, inequal], vars, Reals] $\endgroup$ – b.gates.you.know.what Dec 14 '14 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.