When I tried to use the function "solve" in gem NMatrix, I find wrong result...
I am trying to solve the linear system a*x = b
where
a = [[1, 0, 0],
[4, -5, 1],
[0, 0, 1]]
and
b = [0, 0, 729]
Which should give the answer
x = [0, 145.8, 729]
I call the solve function doing a.solve(b)
(as explained at http://www.rubydoc.info/gems/nmatrix/0.2.1/NMatrix#solve-instance_method) but it returns
x = [0, 1.013500790889141e-30, 1.013500790889141e-30]
Therefore, I have two questions:
- Am I doing something wrong?
- If not, what would be the other solution (excluding GSL) to solve matrix systems with ruby?
Thank you !