1

I have the following system of equations that I need to solve:

ArrayOfEquations={-(u/10) + 0.4 v[1] - 0.16 v[2] + 0.064 v[3] - 0.0256 v[4] + 
0.01024 v[5] - 0.004096 v[6] + 0.0016384 v[7] - 0.00065536 v[8] + 
0.000262144 v[9] == g[1], 
-0.4 v[1] + 0.32 v[2] - 0.192 v[3] + 0.1024 v[4] - 
0.0512 v[5] + 0.024576 v[6] - 0.0114688 v[7] + 0.00524288 v[8] - 
0.0023593 v[9] == g[2], 
-0.16 v[2] + 0.192 v[3] - 0.1536 v[4] + 0.1024 v[5] - 
0.06144 v[6] + 0.0344064 v[7] - 0.0183501 v[8] + 0.00943718 v[9] ==g[3], 
-0.064 v[3] + 0.1024 v[4] - 0.1024 v[5] + 0.08192 v[6] - 
0.057344 v[7] + 0.0367002 v[8] - 0.0220201 v[9] == g[4], 
-0.0256 v[4] + 0.0512 v[5] - 0.06144 v[6] + 0.057344 v[7] - 
0.0458752 v[8] + 0.0330301 v[9] == g[5], 
-0.01024 v[5] + 0.024576 v[6] - 0.0344064 v[7] + 
0.0367002 v[8] - 0.0330301 v[9] == g[6], 
-0.004096 v[6] + 0.0114688 v[7] - 0.0183501 v[8] + 
0.0220201 v[9] == g[7], 
-0.0016384 v[7] + 0.00524288 v[8] - 0.00943718 v[9] == g[8], 
-0.00065536 v[8] + 0.0023593 v[9] == g[9], 
-0.000262144 v[9] == g[10]}

I want to solve it for variables $u$ and $v[i]$, $i=1,..9$. When I call

Solve[ArrayOfEquations, Join[{u}, Array[v, 9]]]

I get {} as an output.

Why doesn't it work?

I understand that {} in general means no solution. However, I tried it with some numbers substituted for g[i] and got a numerical output. Can't understand what goes wrong if I keep the g[i] symbolically

Thanks for any help!

Kuba
  • 136,707
  • 13
  • 279
  • 740
GregVoit
  • 157
  • 8
  • 1
    ToRules@Reduce[ArrayOfEquations, Join[{u}, Array[v, 9]]] – Dr. belisarius May 15 '14 at 13:28
  • 1
    ...or add ,Reals as an option at the end – gpap May 15 '14 at 13:30
  • @belisarius I don't understand the output if I give your code line. For example, if I put Solve[ArrayOfEquations[[10]], v[9]], then I get v[9] -> -3814.7 g[10]. However, with your solution I get a different expression. Where do all the other terms come from? From the last equation, it's clear that for v[9] the answer is simple... – GregVoit May 15 '14 at 13:32
  • @gpap the same output as from belisarius... – GregVoit May 15 '14 at 13:33
  • Please see (for example)http://mathematica.stackexchange.com/a/18706/193 – Dr. belisarius May 15 '14 at 13:35
  • @belisarius I don't really see how that relates to my problem. There, they are explaining the different forms of the output (or it may seem strange to people). However, the actual numbers in the output make sense, and in my case they don't. Any way I could maybe explain that? – GregVoit May 15 '14 at 13:39
  • @GregVoit Oh,OK. It's a rounding problem. Try s = ToRules@Reduce[ArrayOfEquations, Join[{u}, Array[v, 9]]]; v[9] /. Chop@s – Dr. belisarius May 15 '14 at 13:42
  • @belisarius ah, I see. But I still find it weird (from the math point of view) where the extra terms in the expression for v[9] came from, whether we round them or not, by looking at the last equation they just can't be there. Or am I misunderstanding again? – GregVoit May 15 '14 at 13:46
  • @GregVoit The effect disappears if you work with exact numbers instead.s = ToRules@ Reduce[Rationalize[#, 0] &@ArrayOfEquations, Join[{u}, Array[v, 9]]]; The method used for solving linear systems may introduce that kind of "inaccuracies". In fact if the system is ill-conditioned you may get really wrong results depending on the numerical error. – Dr. belisarius May 15 '14 at 13:55
  • @belisarius I understand now. Thank you very much! – GregVoit May 15 '14 at 13:59

1 Answers1

1

Your equations are actually inconsistent unless $g$ has a particular form.

When I rationalise and solve, I obtain the following requirements on the solution

{True,
 7.10543*10^-15 g[7] + 7.10543*10^-15 g[8] + 7.10543*10^-15 g[9] == 0, 
 3.55271*10^-15 g[6] + 5.68434*10^-14 g[9] == 0,
 True,
 True, 
 1.11022*10^-16 g[6] + 8.88178*10^-16 g[7] + 3.55271*10^-15 g[8] + 7.10543*10^-15 g[9] == 0,
 True, True, True, True}

As others have said, this is a rounding error problem: when you substitute numerical values for g, those small terms will become very close to 0..

Patrick Stevens
  • 6,107
  • 1
  • 16
  • 42