Let's say that A
is an m-by-n matrix, and that b
is a n
-dimensional vector. You want to know all the solution to A x = b
in the case of m<n
, and it is expressed as following:
x = x_0 + K y
, .. (1)
where x_0
is an arbitrary solution to the original equation, A x = b
, K
is a n
-by-(n-m)
matrix whose columns constitute a basis of the null space (also called kernel) of A
, and y
is an arbitrary (n-m)
-dimensional vector. This y
corresponds to what you call "free parameter".
Let me explain about the matrix K
more. The null space of the matrix A
is a set of vectors v
such that A v = 0
. This set of v
is actually a vector space of (n-m)
-dimension, and any v
can be expressed as a linear combination of (n-m)
vectors, k_1
, .., k_{n-m}
, which are linearly independent with each other and satisfy A k_i = 0
(i=1,..,n-m
). The choice of k_1,..,k_{n-m}
is not unique.
You can substitute eq. (1) to A x =b
to verify that it's indeed the solution because A K = 0
. The term K y
expresses all vectors v
such that A v=0
.
One method to find the matrix K
is the singular value decomposition,
A V = U S
,
where V
and U
are n
-by-n
and m
-by-m
orthogonal matrices, respectively, and S
is a m
-by-n
diagonal matrix like,
S = [s_1 0 0 0 0 ]
[ 0 s_2 0 0 0 ]
[ 0 0 s_3 0 0 ]
Since the last (n-m)
columns of S
are zero vectors, the last (n-m)
columns of the product U S
are also zero vectors. This means that the last (n-m)
columns of V
will yield zero vectors if we multiply A
on them from the left. Therefore, these columns of V
belongs to the null space of A
. As they are linearly independent (as V
is an orthogonal matrix), they constitute the basis of the null space. Therefore, we can set K
as the last (n-m)
columns of V
found in the singular value decomposition.
I don't know how to do the singular value decomposition in Matlab, but there must be a function for it.