We can use MATLAB to solve the system ax=b
for different values of b
with the given matrix a
and maximum relative error of 0.0120 in 1-norm. One way to do this is to use the \
operator to perform the matrix division x=a\b
, which will give us the solution x
for the given right-hand side b
.
To introduce the maximum relative error, we can use the norm
function to calculate the 1-norm of the error e=b-a*x
and compare it to the 1-norm of b
multiplied by the maximum relative error. If the error is too large, we can adjust b
and try again.
Here's some MATLAB code to implement this approach:
main.m782 chars24 lines
This code loops over 10 different randomly generated right-hand side vectors, each with 1-norm of 1 and maximum relative error 0.0120. It solves the system for each b
using the \
operator, checks the error using the norm
function, and displays the solution x
for each b
.
Note that the actual values of b
that we get will depend on the problem we are trying to solve, and the way we generate them will also depend on the specific requirements of the problem.
gistlibby LogSnag