Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

perform the following in matlab let b be a vector of all ones. for n=10, 100, 10

ID: 1990175 • Letter: P

Question

perform the following in matlab

let b be a vector of all ones. for n=10, 100, 1000, 2000, 4000, 8000:

(parta) create the matrix A by first creating a matrix of all 0's the putting in the -2's on the main diagonal and 1's on the first upper and lower diagonals.

solve Ax=b using backslash, and time it using tic and toc. Hint: using the diag command help here

(partb)repeat the process, but using the sparse matrix format for A. You can do this inefficiently by using sparse command to turn your matrivces from parta into sparse format. A much better way to do this is to create the matrix using the spdiags command. the syntax to do this can be found in the help documentation of spdiags . is there a timing diffrence between solving sparse and full matrices using backslash? how much?

Explanation / Answer

AX = B

X = A-1 B

let b be a vector of all ones. for n=10, 100, 1000, 2000, 4000, 8000

then X and A also having dimension of n