[R] Finding solution set of system of linear equations.

dslowik dslowik at tellink.net
Sun May 22 03:34:20 CEST 2011


I have a simple system of linear equations to solve for X, aX=b:
> a
     [,1] [,2] [,3] [,4]
[1,]    1    2    1    1
[2,]    3    0    0    4
[3,]    1   -4   -2   -2
[4,]    0    0    0    0
> b
     [,1]
[1,]    0
[2,]    2
[3,]    2
[4,]    0

(This is ex Ch1, 2.2 of Artin, Algebra).
So, 3 eqs in 4 unknowns. One can easily use row-reductions to find a
homogeneous solution(b=0) of: 
X_1 = 0, X_2 = -c/2, X_3 = c,  X_4 = 0

and solutions of the above system are:
X_1 = 2/3, X_2 = -1/3-c/2,  X_3 = c, X_4 = 0.

So the Kernel is 1-D spanned by X_2 = -X_3 /2, (nulliity=1), rank is 3.

In R I use solve():
> solve(a,b)
Error in solve.default(a, b) : 
  Lapack routine dgesv: system is exactly singular

and it gives the error that the system is exactly singular, since it seems
to be trying to invert a.
So my question is:
Can R only solve non-singular linear systems? If not, what routine should I
be using? If so, why? It seems that it would be simple and useful enough to
have a routine which, given a system as above, returns the null-space
(kernel) and the particular solution.




--
View this message in context: http://r.789695.n4.nabble.com/Finding-solution-set-of-system-of-linear-equations-tp3541490p3541490.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list