> Why do
> x<-b%*%ginv(A)
> and
> x<-solve(A,b)
> give different results?.

they do (in cases the solution to A x = b is unique):

R> A <- matrix(c(0,-4,4,0),nrow=2,ncol=2)
R> A
     [,1] [,2]
[1,]    0    4
[2,]   -4    0
R> b <- c(-16,0)
R> x1 <- ginv(A) %*% b          <- NOT b %*% ginv(A)
R> x1
     [,1]
[1,]    0
[2,]   -4
R> x2 <- solve(A) %*% b
R> x2
     [,1]
[1,]    0
[2,]   -4
R> x3 <- solve(A, b)
R> x3
[1]  0 -4

Torsten


> It seems that I am missing some basic feature of
> matrix indexing.
> e.g.:
>
> A<-matrix(c(0,-4,4,0),nrow=2,ncol=2)
> b<-c(-16,0)
> x<-b%*%ginv(A);x
> x<-solve(A,b);x
>
> Thanks in advance,
> Angel
>
> ______________________________________________
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to