Exercise 1.7.8. Take the 10 by 10 Hilbert matrix for which and solve the equation . Make a minor change to or and see how the solution changes.

Answer: We can use the open source statistics software R for this exercise. The following R commands will define a 10 by 10 Hilbert matrix. The first command defines as a 10 by 10 matrix with all values set to 0, and the second command sets each entry to the proper value for a Hilbert matrix. (Note that there may be a faster or more elegant way to do this in R, but this way is easily understandable.)

> A <- array(0, dim=c(10,10)) > for (i in 1:10) {for (j in 1:10) {A[i, j] <- 1/(i+j-1)}} >

We then print the matrix to double-check that it appears to be correct (we use the option() function to limit the number of digits printed per entry and increase the width of the printable area, so that the entire matrix can be displayed more compactly):

> options(digits=3) > options(width=90) > A [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1.000 0.500 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 [2,] 0.500 0.333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 0.0909 [3,] 0.333 0.250 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 0.0909 0.0833 [4,] 0.250 0.200 0.1667 0.1429 0.1250 0.1111 0.1000 0.0909 0.0833 0.0769 [5,] 0.200 0.167 0.1429 0.1250 0.1111 0.1000 0.0909 0.0833 0.0769 0.0714 [6,] 0.167 0.143 0.1250 0.1111 0.1000 0.0909 0.0833 0.0769 0.0714 0.0667 [7,] 0.143 0.125 0.1111 0.1000 0.0909 0.0833 0.0769 0.0714 0.0667 0.0625 [8,] 0.125 0.111 0.1000 0.0909 0.0833 0.0769 0.0714 0.0667 0.0625 0.0588 [9,] 0.111 0.100 0.0909 0.0833 0.0769 0.0714 0.0667 0.0625 0.0588 0.0556 [10,] 0.100 0.091 0.0833 0.0769 0.0714 0.0667 0.0625 0.0588 0.0556 0.0526 >

We next define :

> b <- array(0, dim=c(10)) > b[1] <- 1 > b [1] 1 0 0 0 0 0 0 0 0 0 >

We can now use the R solve() function to solve for :

> x <- solve(A, b) > x [1] 100 -4950 79195 -600553 2522294 -6305679 9608580 -8750614 4375282 [10] -923666 >

We then multiply by to verify that is indeed a solution to :

> A %*% x [,1] [1,] 1.00e+00 [2,] -1.89e-10 [3,] -2.04e-10 [4,] -1.60e-10 [5,] -1.02e-10 [6,] 3.64e-11 [7,] 2.18e-11 [8,] 7.28e-11 [9,] 0.00e+00 [10,] 0.00e+00 >

Finally we tweak very slightly and see how the solution to changes:

> b2 <- b > b2[10] <- .01 > b2 [1] 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 > x2 <- solve(A, b2) > x2 [1] -9.14e+03 8.26e+05 -1.82e+07 1.70e+08 -8.30e+08 2.32e+09 -3.87e+09 3.80e+09 [9] -2.02e+09 4.48e+08 >

Note that the very minor change to caused the entries of the solution to change by one or more orders of magnitude.

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books.