1. Math
  2. Advanced Math
  3. could you please help me solve the matlab problem thanks...

Question: could you please help me solve the matlab problem thanks...

Question details

Could you please help me solve the Matlab problem, thanks

Finite-Precision Errors in GE for Large Linear Systems Begin by downloading the in-class demo w02w.GEerrm from this demo produced the distribution of errors resulting from the Gaussian Elimination (GE) algorithm with finite-precision arithmetic. The goal of this exercise is to understand the statistics of the growth of truncation error as matrix size N increases. the Canvas page. Recall, from lecture, that As presented in the notes, a brief summary of the experimental method is produce a random matrix [A, construct the right-side vector b = [Alz0, where zo is the N-component vector of all 1s (using the Matlab ones command), use Matlabs backslash to get the GE solution-[A] b, . compute the finite-precision solution error, sol-err-rms(,-z), . compute the finite-precision residual error, res.err rms([A b), o gather data for statistical analysis. The rms command is Matlab is the Root-Mean-Squared (RMS) function, which converts the vector of errors to a non-negative scalar number 1피 rms(E) where is the vector magnitude, which is then divided by the number of components ofso it gives a measure of the error per unknown (so we dont grow the error when comparing to ever larger N values.) Furthermore, by considering the logio of the RMS error, it is basically converted into a number that roughly indicates the first corrupted decimal place (as in its power of 10) In exact arithmetic, we should expect the errors to be 0. However as seem in lecture, in the world of floating-point arithmetic, even small matrix-size results in measurable non-zero errors. You will learn in this exercise that, as N increases, so do the GE errors and the goal of this assignment is to produce a rough estimate for the matrix size N* at which the error resulting from GE becomes as large as the solution itself Of course, it is not possible to do computations for matrices of size N*. Therefore, we will have to do computations for a number of smaller N values, and use these to obtain a rough, but logical, estimate for the value of N*. Since the error computed for each GE depends on the random matrix A, we can determine what the typical error for matrix size N is by averaging over many experiments (different random matrices). If we run Ner number of experiments, and call res err() the errors obtained from the kth experiment, we can then define the average logio error as eres errl) We will take this error to be representative of the typical GE error for matrices of size N. Once you have several of these Ere (N) values, show them in a plot which you then base your estimate for N*Your one-page computing report should include/address the following: (a) Obtain values Eres(N) for several different values of N. But to do this, YOU will need to decide on the values for N and Nerp to be used. All of these choices will affect the quality of your estimate. Clearly indicate which values you selected and discuss how you made your choices. (b) Include a plot of the points (log1o N, Eres(N)). (c) Use your plot from (b) to argue for your value of an estimated value N where Eres(N) 0. You only need to present a rough order of magnitude here, and you should indicate how achievable, or not, your value of N* is.

some of main code has been provided, please follow the question and complete the code first:

%  N = matrix size;  Nex = # of experiments
N = 1*128
Nex = 1*100;

%  solution of all ones
x0 = ones(N,1);

%  data vector of errors
res_err = zeros(Nex,1);
sol_err = zeros(Nex,1);

for kk = 1:Nex
        %  make random matrix & b-vector
        A = eye(N,N) + randn(N,N)/sqrt(N);
        b = A*x0;

        %  GE via backslash
        x1 = A  b;

        %  rms residual error 
        res_err(kk) = rms(A*x1-b);

        % rms solution error
        sol_err(kk) = rms(x1-x0);

%  histogram for residual error
figure(1);  clf

%  mean & variance
min_re = min(log10(res_err));

string = ['mean = ' num2str(mean(log10(res_err)))]
string = ['var  = ' num2str(var(log10(res_err)))]

%  axis labels
xlabel('log_{10} rms error','fontsize',12)
ylabel(['number from ' num2str(Nex) ' experiments'])
title('residual error: A x_1- b','fontsize',14)

%  plot for solution error
xlabel('log_{10} rms error','fontsize',12)
ylabel(['number from ' num2str(Nex) ' experiments'])
title('solution error: x_1-x_0','fontsize',14)
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution