

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Spring 2004 Solutions to HW 3 Assigned: Thurs Feb 5, 2004; Due: Thurs Feb 12, 2004
Homework problems will be posted in the course directory: www.cs.odu.edu/˜pothen/Courses/CS417. If any corrections are found to be neces- sary, they will be posted in this directory as well. You must show your work to receive credit for your answers. In problems where you are asked to give reasons, an answer without a stated reason will receive no credit.
hij = 1/(i + j − 1), for i = 1, 2 ,... , n; j = 1, 2 ,... , n.
(a) J = 1 : n; Creates a vector with elements being 1 through n. J = J(ones(n,1) ,: ); Copies the J vector n times. I = J; Creates a matrix I which is J transpose. E = ones(n,n); Creates a matrix E which is n x n matrix of ones. H = E. / (I + J - 1); Creates the Hilbert matrix by perform element by element divi- sion.
(b) H = hilb(n); Creates a Hilbert matrix of order n. b = sum(H,2); Creates a right hand side vector b such that the exact solution to Hx = b is the vector of all ones. x = H \ b Solves the system of equations Hx = b in Matlab, x is shown in Figure 1. (c) The difference between the computed solution and the exact solution e. The predict errors e(n) = cond(hilb(n)) * eps, e(10) = 0.0036, e(20) = 424, e(30) = 1.3741e+003. The errors is correctly predicted using e(n)
0 2 4 6 8 10
1
0 5 10 15 20
−
−
0
20
40
60
0 10 20 30
−
−
0
500
0 10 20 30 40
−
−
0
200
400
600
Figure 1: The values of x when Hilbert matrix sizes: n = 10, n = 20, n = 30 and n = 40.