Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am having issues getting the code to work properly. My code below: I receiving the following error: Do I need to to add one

image text in transcribedI am having issues getting the code to work properly. My code below:

image text in transcribed

I receiving the following error:

image text in transcribed

Do I need to to add one n value at a time or do I need to put all the n values together within the code?

For n= 50, 100, 200, 300, 400, do the following. Let A be the n-by-n matrix with entries Aij = 1/(\i 312 + 1). With repmat in MATLAB, you can construct this matrix in two lines. Define Xexact = (1,1, ..., 1)?, and then compute b = Axexact. Using MATLAB's backslash, numerically solve the equation Ax = b, thereby producing a computed solution X. In exact arithmetic xa = Xexact of course, but in IEEE double precision XA will not equal Xexact. The quantity ||X A Xexact || oo is the forward error. Construct a table which, for each n, collects the relative forward error, relative backward error, magnification factor, and (infinity-norm) condition number of A. Discuss your results. II n = [50, 100, 200, 300, 400]; A zeros (n,n); for i = 1:n for j = l:n Ali,j) = 1/((abs (i-j)^2)+1); end end x_exact = ones (n,1); b = A*X_exact; X = A b; bl = A*X; REE norm (x-x_exact, inf)orm (x_exact, inf) RBE = norm (b-bi, inf) orm (b, inf) ME = RFE/RBE kocond (A, inf) Error using zeros Size inputs must be scalar. Error in condition (line 42) A = zeros (n,n); For n= 50, 100, 200, 300, 400, do the following. Let A be the n-by-n matrix with entries Aij = 1/(\i 312 + 1). With repmat in MATLAB, you can construct this matrix in two lines. Define Xexact = (1,1, ..., 1)?, and then compute b = Axexact. Using MATLAB's backslash, numerically solve the equation Ax = b, thereby producing a computed solution X. In exact arithmetic xa = Xexact of course, but in IEEE double precision XA will not equal Xexact. The quantity ||X A Xexact || oo is the forward error. Construct a table which, for each n, collects the relative forward error, relative backward error, magnification factor, and (infinity-norm) condition number of A. Discuss your results. II n = [50, 100, 200, 300, 400]; A zeros (n,n); for i = 1:n for j = l:n Ali,j) = 1/((abs (i-j)^2)+1); end end x_exact = ones (n,1); b = A*X_exact; X = A b; bl = A*X; REE norm (x-x_exact, inf)orm (x_exact, inf) RBE = norm (b-bi, inf) orm (b, inf) ME = RFE/RBE kocond (A, inf) Error using zeros Size inputs must be scalar. Error in condition (line 42) A = zeros (n,n)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions