I have a simple system of linear equations to solve for X, aX=b:
> a
[,1] [,2] [,3] [,4]
[1,]1211
[2,]3004
[3,]1 -4 -2 -2
[4,]0000
> b
[,1]
[1,]0
[2,]2
[3,]2
[4,]0
(This is ex Ch1, 2.2 of Artin, Algebra).
So, 3 eqs
solve() only works for nonsingular systems of equations.
Use a generalized inverse for singular systems:
> A<- matrix(c(1,2,1,1, 3,0,0,4, 1,-4,-2,-2, 0,0,0,0), ncol=4, byrow=TRUE)
> A
[,1] [,2] [,3] [,4]
[1,]1211
[2,]3004
[3,]1 -4 -2 -2
[4,]0
Thanks Robert. That all seems to work. I also found the MASS::Null() function
that gives the null space for the matrix(transpose) given as argument. I am
still trying to appreciate the math behind the Moore-Penrose inverse matrix.
If you have any suggestions for understanding how to use R to solve
3 matches
Mail list logo