Section
4:
Using Matrix
Operations
2.
Solve
the
following
system
for b:
115
U
g
0 q
0
-Q
(If
q = 0,
replace
it by any
small nonzero number,
say 10
".)
The
-1 in the
solution matrix automatically appears;
it
requires
no
additional calculations.
In the
absence
of
rounding errors,
q =
±||y
—
Xb||^-;
this
may
be
inaccurate
if
\q\s too
small,
say
smaller
than
||y||/106.
If
you
desire
a
more accurate estimate
of ||y
—
Xb||^,
you can
calculate
it
directly
from
X, y, and the
computed solution
b.
For the
weighted least-squares
problem,
replace
X and y by WX
and Wy,
where
W is the
diagonal matrix containing
the
weights.
For the
linearly constrained least-squares problem,
you
must
recognize
that
constraints
may be
inconsistent.
In
addition, they
can't
always
be
satisfied exactly
by a
calculated solution because
of
rounding errors. Therefore,
you
must
specify
a
tolerance
t
such
that
the
constraints
are
said
to be
satisfied when ||Cb
—
d|| < t.
Certainly
t >
||d||/1010
for
10-digit
computation,
and in
some
cases
a
much larger tolerance must
be
used.
Having chosen
t,
select
a
weight factor
w
that
satisfies
w >
\\y\\/t.
For
convenience, choose
w to be a
power
of 10
somewhat bigger
than
||y||/t.
Then
w\\Cb
- d|| >
||y|| unless ||Cb
- d|| < t.
However,
the
constraint
may
fail
to be
satisfied
for one of two
reasons:
•
Nob
exists
for
which
||
Cb
—d||
<
t.
• The
leading columns
of
C are
nearly linearly dependent.
Check
for the
first situation
by
determining whether
a
solution
exists
for the
constraints alone. When
[wC
wd]
has
been factored
to
Q[U
g],
solve
this
system
for b
(k
rows)
U g
(p
4-1
—
&
rows)
I 0
diag(q)
0
-Q
(p
rows)
(1
row)
using
any
small nonzero number
q. If the
computed solution
b
satisfies
Cb
~
d,
then
the
constraints
are not
inconsistent.