[R] What solve() does?

Peng, C cpeng.usm at gmail.com
Fri Sep 3 20:12:37 CEST 2010


If A is a squared matrix, solve(A) gives the inverse of A; if you have a
system of linear equation AX=B, solve(A,B) gives the solution to this system
of equations. For example:

   x-2y =1
-2x+3y=-3

> A=matrix(c(1,-2,-2,3), ncol=2, byrow=T)
> B=c(1,-3)
> 
> # to get the inverse of A
> solve(A)
     [,1] [,2]
[1,]   -3   -2
[2,]   -2   -1
> # to get the solution to the system of equation
> solve(A,B)
[1] 3 1



-- 
View this message in context: http://r.789695.n4.nabble.com/What-solve-does-tp2402922p2526066.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list