NUMERICAL ANALYSIS + MATLAB (Assignment)
only “one” page report
in the assignment attached, there is a demo for matlab
this is the demo:
Gaussian Elimination in floating point arithmetic
Note: Download the in-class demo LSRandom.m before completing this assignment.
*((here is the code for this part for matlab)):
% Class: MACM 316_x000D_ % Title: Gaussian Elimination for a random matrix demo_x000D_ % Description: Computes the mean solution error over Ntr trials for the_x000D_ % system Ax=b where A is a random NxN matrix and x is a vector of ones._x000D_ % Plots the result as a histogram._x000D_ % File name: LSRandom.m_x000D_ _x000D_ N = 10; % Matrix size_x000D_ Ntr = 100; % Number of trials_x000D_ _x000D_ errs = zeros(Ntr,1); % Vector of errors_x000D_ x = ones(N,1); % exact solution vector_x000D_ _x000D_ for i=1:Ntr_x000D_ _x000D_ A = randn(N,N); % Construct a random NxN matrix (normally distributed)_x000D_ b = A*x; % Compute the right-hand side vector_x000D_ z = Ab; % Solve the linear system_x000D_ _x000D_ errs(i) = max(abs(z-x)); % Compute the error_x000D_ end_x000D_ _x000D_ % Compute the mean and standard deviation of the error_x000D_ mean_err = mean(errs)_x000D_ sdev_err = sqrt(var(errs))_x000D_ _x000D_ % Plot a histogram of the errors_x000D_ hist(log10(errs),10)_x000D_ title(['histogram of log_{10}(error) for ' num2str(Ntr) ' solves with a ' num2str(N) 'x' num2str(N) ' matrix'],'fontsize',14)_x000D_ xlabel('log_{10}(error)','fontsize',12)_x000D_ ylabel('number','fontsize',12)