Learn R Programming

Morpho (version 2.12)

solutionSpace: returns the solution space (basis and translation vector) for an equation system

Description

returns the solution space (basis and translation vector) for an equation system

Usage

solutionSpace(A, b)

Value

basis

matrix containing the basis of the solution space

translate

translation vector

Arguments

A

numeric matrix

b

numeric vector

Details

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.

Examples

Run this code
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

Run the code above in your browser using DataLab