Graphics Programs Reference
In-Depth Information
EXAMPLE 2.4
An
n
×
n
Vandermode matrix
A
is definedby
v
n
−
j
i
A
i j
=
,
i
=
1
,
2
,...,
n
,
j
=
1
,
2
,...,
n
where
v
is avector. In MATLAB a Vandermode matrix can be generatedbythe com-
mand
vander(v)
. Use the function
gauss
to compute the solution of
Ax
=
b
, where
A
is the 6
×
6 Vandermode matrix generated from the vector
1
0
T
v
=
.
0 1
.
21
.
4 1
.
61
.
82
.
and
0 1 0 1 0 1
T
b
=
Also evaluate the accuracy of the solution (Vandermode matrices tend to be ill-
conditioned).
Solution
We used the program shown below. After constructing
A
and
b
, the output
format waschanged to
long
so that the solutionwouldbe printed to 14 decimal
places. Here are the results:
% Example 2.4 (Gauss elimination)
A = vander(1:0.2:2);
b=[010101]';
format long
[x,det] = gauss(A,b)
x=
1.0e+004 *
0.04166666666701
-0.31250000000246
0.92500000000697
-1.35000000000972
0.97093333334002
-0.27510000000181
det =
-1.132462079991823e-006
As the determinant isquite small relative to the elements of
A
(you may wantto
print
A
to verify this), weexpect detectable roundoff error. Inspection of
x
leads usto
suspect that the exact solutionis
1250
2751
T
x
=
/
3
−
3125 9250
−
13500 29128
/
3
−
in which case the numerical solutionwouldbe accurate to 9decimal places.
Search WWH ::
Custom Search