Oct 9, 2012 at 6:53 PM
Edited Oct 11, 2012 at 7:38 AM

Hey, thanks for reading,
I have a system of linear equations as follows
[vector]= [matrix] [vector]
(edit  this system is not correct, the correct system is [vector]= [matrix] [vector] + [vector] ) please see the picture linked below.
However, there is a mix of knowns and unknowns in both of the vectors.
This is part of a larger method, so the system will always be well behaved. There will always be as many unknowns as there are equations, and each linear equation will only have a single unknown. However, I have no knowledge before hand if that unknown
will be on the left side or the right side of the equal sign.
Any advice for how to solve for the unknowns? I have looked through the sample code but this problem seems to never be addressed.



If each linear equation only has a single unknown, you can symbolically solve all equations independently. So this is not exactly an equation system, just N independent equations.
Then, all finite linear equation systems can be transformed into standard form Ax=y, where A and y are known and x is unknown (at which point you can use our algorithms to solve it).
Maybe I'm missing something. Can you give an example?



Hey again.
Thanks for your help. I thought I had come up with a solution and I was going to report back once I had implemented it, but it turns out that my solution wasn't one.
Anyway, I am trying to solve the equation shown in this picture:
https://dl.dropbox.com/u/217910/IMAG0081.jpg
I have the matrix "K" and the vector "Ff", but I don't know to solve for the four unknowns.
There doesn't seem to be any code in the samples showing how to deal with this situation.
Thanks again for the help.


Oct 11, 2012 at 8:39 AM
Edited Oct 11, 2012 at 8:39 AM

So here's what I think I should do:
pull out degrees of freedom 2 and 4 to get this equation
{0,0} = {{.4,.2},{.2,.4}}{d2,d4) + {20.16,30.24}
Which is easy enough to solve with LU Decomposition
Then take the resulting d2 and d4 and plug them back into the equation, solving for F1 and F3
Is that the best approach?


Oct 12, 2012 at 8:51 AM
Edited Oct 12, 2012 at 8:51 AM

Exactly, except there's no need to solve for F1 and F3 then, as they can then be directly evaluated:
F# code sample:
open MathNet.Numerics.LinearAlgebra.Double
open MathNet.Numerics.FSharp
let d = (matrix [[0.4;0.2];[0.2;0.4]]).LU().Solve(vector [20.16;30.24])
let F = (matrix [[0.06;0.06];[0.06;0.06]]) * d + vector [7.39;13.6]
printfn "d2=%A d4=%A F1=%A F3=%A" d.[0] d.[1] F.[0] F.[1]
Which returns d2=117.6 d4=134.4 F1=8.398 F3=12.592 on my system


Oct 12, 2012 at 9:02 AM
Edited Oct 12, 2012 at 12:22 PM

Btw, alternatively you could bring it into normal form as I mentioned above and solve it in one go:
// Ax=b
let A = matrix [[1.0;0.0;0.06;0.06];[0.0;0.0;0.4;0.2];[0.0;1.0;0.06;0.06];[0.0;0.0;0.2;0.4]]
let b = vector [7.39;20.16;13.6;30.24]
let x = A.LU().Solve(b)
printfn "d2=%A d4=%A F1=%A F3=%A" x.[2] x.[3] x.[0] x.[1]
Which returns exactly the same solution as above. As you can see, I moved F1 and F3 to the right side (i.e. substracted it from both sides) as the first two columns, with coefficients 0 or 1.

