Solving simultaneous equations with R
问题 Suppose I have the following equations: x + 2y + 3z = 20 2x + 5y + 9z = 100 5x + 7y + 8z = 200 How do I solve these equations for x , y and z ? I would like to solve these equations, if possible, using R or any other computer tools. 回答1: This should work A <- matrix(data=c(1, 2, 3, 2, 5, 9, 5, 7, 8), nrow=3, ncol=3, byrow=TRUE) b <- matrix(data=c(20, 100, 200), nrow=3, ncol=1, byrow=FALSE) round(solve(A, b), 3) [,1] [1,] 320 [2,] -360 [3,] 140 回答2: For clarity, I modified the way the matrices