To solve the system Ax=b, we can use MATLAB's A \ b command. For different b's, we can put them in a matrix B where each column corresponds to a different b. Then we can use the same A and solve Ax=b for each column of B using A \ B.
To calculate the large relative error of the right hand side 1-norm, we can use the following steps:
Ax=b for each column of B using X = A \ BB_new by multiplying A and X: B_new = A * XB and B_new: delta_B = B - B_newB: norm_B = norm(B, 1)delta_B: norm_delta_B = norm(delta_B, 1)err = norm_delta_B / norm_BHere's the MATLAB code to accomplish this:
main.m208 chars10 lines
Note that I've used B = [1 2 3; 4 5 6; 7 8 9] as an example for B. You can replace it with any other matrix of appropriate dimensions.
gistlibby LogSnag