0
$\begingroup$

This is my current code and i'm not sure why it's not working. I am new to Mathematica, though.

FindInstance[{-11 "x1" - 20 "x2" - 9 "x3" + 8 "x4" - 9 "x5" - 14 "x6" - 9 "x7" - 11 "x8" + 3 "x9" == 1 && 9 "x1" + 19 "x2" + 20 "x3" - 12 "x4" + 2 "x5" - 13 "x6" - 17 "x7" + 10 "x8" + 17 "x9" == -14 && 15 "x1" + 2 "x2" + 17 "x3" + 15 "x4" - 20 "x5" - 10 "x6" - "x7" + 9 "x8" + 8 "x9" == -6 && 13 "x1" + 13 "x2" - 8 "x3" + 5 "x4" - 8 "x5" - 12 "x6" + 11 "x7" - 19 "x8" + 11 "x9" == -17 && -18 "x1" - 5 "x2" - 18 "x3" - 7 "x4" - 2 "x5" - 20 "x6" + 2 "x7" - 5 "x8" - 17 "x9" == -1 && -3 "x1" - 7 "x2" + 2 "x3" + 5 "x4" - 9 "x5" - 8 "x6" - 4 "x7" + 18 "x8" - 9 "x9" == -18 && 4 "x1" + 18 "x2" + 5 "x3" + 15 "x4" + 14 "x5" - 7 "x6" + 2 "x7" + 8 "x8" - 14 "x9" == 5 && -15 "x1" + "x2" - 16 "x3" - 16 "x4" + 3 "x5" - 5 "x6" - 10 "x7" + 7 "x8" + 16 "x9" == 5 && -5 "x1" + 7 "x2" + "x3" - 13 "x4" - 4 "x5" + 14 "x6" - 19 "x7" + "x8" - 14 "x9" == 8}, {x1, x2, x3, x4, x5, x6, x7, x8, x9}, Reals]

Here is the error that I am getting: FindInstance::exvar: The system contains a nonconstant expression x1 independent of variables {x1,x2,x3,x4,x5,x6,x7,x8,x9}.

Here are the equations on their own:

-11 x1-20 x2-9 x3+8 x4-9 x5-14 x6-9 x7-11 x8+3 x9==19 
x1+19 x2+20 x3-12 x4+2 x5-13 x6-17 x7+10 x8+17 x9==-14
15 x1+2 x2+17 x3+15 x4-20 x5-10 x6-x7+9 x8+8 x9==-6
13 x1+13 x2-8 x3+5 x4-8 x5-12 x6+11 x7-19 x8+11 x9==-17
-18 x1-5 x2-18 x3-7 x4-2 x5-20 x6+2 x7-5 x8-17 x9==-1
-3 x1-7 x2+2 x3+5 x4-9 x5-8 x6-4 x7+18 x8-9 x9==-18
4 x1+18 x2+5 x3+15 x4+14 x5-7 x6+2 x7+8 x8-14 x9==5
-15 x1+x2-16 x3-16 x4+3 x5-5 x6-10 x7+7 x8+16 x9==5
-5 x1+7 x2+x3-13 x4-4 x5+14 x6-19 x7+x8-14 x9==8

I was experementing with the FindInstance function because I believe the Solve function can only do it for up to 4 variables, but again I could be wrong. What's the best way to do this? I'm on Mathematica 10 if that makes any difference.

$\endgroup$
3
  • $\begingroup$ Why are you using quotes in the first part of your question ? $\endgroup$
    – Sektor
    Mar 20, 2015 at 23:29
  • $\begingroup$ Solve has no problems finding the solution. $\endgroup$
    – Jens
    Mar 20, 2015 at 23:30
  • $\begingroup$ Oh wow, it must have added that on it's own for some reason when I was copying and pasting the equations. Removing the quotation marks using Replace All fixed the problem. Thanks for your time though, guys! $\endgroup$ Mar 20, 2015 at 23:34

1 Answer 1

1
$\begingroup$

Just use Solve :

Solve[
 -11 x1 - 20 x2 - 9 x3 + 8 x4 - 9 x5 - 14 x6 - 9 x7 - 11 x8 + 3 x9 == 19
    x1 + 19 x2 + 20 x3 - 12 x4 + 2 x5 - 13 x6 - 17 x7 + 10 x8 + 17 x9 == -14
    15 x1 + 2 x2 + 17 x3 + 15 x4 - 20 x5 - 10 x6 - x7 + 9 x8 + 8 x9 == -6
    13 x1 + 13 x2 - 8 x3 + 5 x4 - 8 x5 - 12 x6 + 11 x7 - 19 x8 + 11 x9 == -17
   - 18 x1 - 5 x2 - 18 x3 - 7 x4 - 2 x5 - 20 x6 + 2 x7 - 5 x8 - 17 x9 == -1
   - 3 x1 - 7 x2 + 2 x3 + 5 x4 - 9 x5 - 8 x6 - 4 x7 + 18 x8 - 9 x9 == -18
    4 x1 + 18 x2 + 5 x3 + 15 x4 + 14 x5 - 7 x6 + 2 x7 + 8 x8 - 14 x9 == 5
   - 15 x1 + x2 - 16 x3 - 16 x4 + 3 x5 - 5 x6 - 10 x7 + 7 x8 + 16 x9 == 5
   - 5 x1 + 7 x2 + x3 - 13 x4 - 4 x5 + 14 x6 - 19 x7 + x8 - 14 x9 == 8,
 {x1, x2, x3, x4, x5, x6, x7, x8, x9}]//N

(*Output*)
{{x1 -> -0.0237652, x2 -> 0.145384, x3 -> -0.0602061, x4 -> -0.265444,
   x5 -> -0.192723, x6 -> -0.742151, x7 -> -0.115203, x8 -> -0.030735,
   x9 -> -0.423858}}
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.