qrSolve.RdSystems of linear equations via QR decomposition.
qrSolve(A, b)Solves (overdetermined) systems of linear equations via QR decomposition.
The solution of the system as vector.
Trefethen, L. N., and D. Bau III. (1997). Numerical Linear Algebra. SIAM, Society for Industrial and Applied Mathematics, Philadelphia.
A <- matrix(c(0,-4,2, 6,-3,-2, 8,1,-1), 3, 3, byrow=TRUE)
b <- c(-2, -6, 7)
qrSolve(A, b)
#> [1] 1 2 3
## Solve an overdetermined linear system of equations
A <- matrix(c(1:8,7,4,2,3,4,2,2), ncol=3, byrow=TRUE)
b <- rep(6, 5)
x <- qrSolve(A, b)
qr.solve(A, rep(6, 5)); x
#> [1] 1.074236 -2.331878 2.436681
#> [1] 1.074236 -2.331878 2.436681