code with octave plz We have seen in class that the relative error in the soluti
ID: 3833608 • Letter: C
Question
code with octave plz
We have seen in class that the relative error in the solution of a linear system due to perturbations E in the matrix A and delta b in the right hand side b can be bounded as ||delta x||/||x|| lessthanorequalto cond(A) (||delta b||/||b|| + ||E||/||A||). This is a worst-case bound. In this exercise your task is to empirically evaluate how tight this analytical bound is and how the relative error in practice relates to this bound. For this purpose, proceed as follows: Consider the 1-norm and n = 100: 50: 1500 For each n, generate - a single random delta b with ||delta b||_1 = 10^-8 - a single random E with ||E||_1 = 10^-8 - many random A and b For each n, compute the averages of the left and right hand sides of the bound (1) over the randomly generated input data A and b. Plot the averages of the left and right hand sides of the bound (1) over n. What are your conclusions?Explanation / Answer
For calculating the 1- norm and plotting the averages of the left and right hand sides of the bound is being done over here. I have written the octave program along with the comments for each of them.
Octave Program:
// Initalize the z value by taking it from 1-norm
z = 50;
// Defined a alpha variable with value as 0.1
alpha = 0.1;
// We need to use the colloc function for plotting it left and right.
[r, x, y] = colloc (z-2, 'left', 'right');
// Assign the leftPlot object to the function
leftPlot = x(2:z-1,2:z-1);
// Assign the rightPlot object to the function
rightPlot = y(2:z-1,2:z-1);
// Finally, Gives the average right value of the plotting.
avgRight = alpha * y(2:z-1,z) - x(2:z-1,z);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.