
This is an example of what I'm trying to solve:
 1 2 3 4   0   F 
 2 3 4 5   0  =  M
 3 4 5 6   V   20
 4 5 6 7   T   0 
Where I am trying to find V, T, F and M. How could this be handled with Math.NET?
Any help is really appreciated.


Coordinator
Oct 22, 2013 at 11:43 AM
Edited Oct 22, 2013 at 11:53 AM

Math.NET Numerics can't solve symbolically, so you'll have to transform it into standard form yourself:
First, the first two values of the solution vector [0;0;V;T] are constant, and in fact 0, so we can simplify the system to:
 3 4   F 
 4 5   V  =  M 
 5 6   T   20 
 6 7   0 
Then we need to subtract the two unknows from the right side back from the left (so they become zero), by introducing a new column each:
First we subtract [F,0,0,0] from both sides:
 3 4 1   0 
 4 5 0   V  =  M 
 5 6 0   T   20 
 6 7 0   F   0 
Then we subtract [0,M,0,0] from both sides the same way:
 3 4 1 0   V   0 
 4 5 0 1   T  =  0 
 5 6 0 0   F   20 
 6 7 0 0   M   0 
And we can solve normally with Math.NET Numerics:
var m = DenseMatrix.OfArray(new double[,] {
{ 3, 4, 1, 0 },
{ 4, 5, 0, 1 },
{ 5, 6, 0, 0 },
{ 6, 7, 0, 0 }
});
var x = m.Solve(new DenseVector(new double[] { 0, 0, 20, 0 }));
Which yields [V,T,F,M] = [140, 120, 60, 40]. When we insert V and T back into the original left side, we get [60, 40, 20, 0] for the right side as expected.



That's very helpful, thank you very much :). I am not very good with matrices so your concise and clear explanation will help enormously.
Thanks again.

