View source: R/solutionSpace.r
solutionSpace | R Documentation |
returns the solution space (basis and translation vector) for an equation system
solutionSpace(A, b)
A |
numeric matrix |
b |
numeric vector |
For a linear equationsystem, Ax = b
, the solution space then is
x = A^* b + (I - A^* A) y
where A^*
is the Moore-Penrose pseudoinverse of A
.
The QR decomposition of I - A^* A
determines the dimension of and basis of the solution space.
basis |
matrix containing the basis of the solution space |
translate |
translation vector |
A <- matrix(rnorm(21),3,7)
b <- c(1,2,3)
subspace <- solutionSpace(A,b)
dims <- ncol(subspace$basis) # we now have a 4D solution space
## now pick any vector from this space. E.g
y <- 1:dims
solution <- subspace$basis%*%y+subspace$translate # this is one solution for the equation above
A%*%solution ## pretty close
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.