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

From: dslowik <dslowik_at_tellink.net>
Date: Sat, 21 May 2011 18:34:20 -0700 (PDT)


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.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 22 May 2011 - 02:36:32 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 23 May 2011 - 02:40:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive