Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Consider the matrix that arises from solving boundary value ODEs from Chapter 4's 'convDiffReact' function, but without reaction or convection. This matrix A has 2
Consider the matrix that arises from solving boundary value ODEs from Chapter 4's 'convDiffReact' function, but without reaction or convection. This matrix A has 2 for each diagonal entry, 1's on each of the first upper and lower diagonals, and the rest of the matrix is all 0's. Such a matrix is considered to be sparse because is 3. consists of mostly O's. Let b be a vector of all ones. For n - 10, 100, 1000, 2000, 4000, 8000: (a) Create the matrix A by first creating a matrix of all O's, then putting in the -2s on the main diagonal and 1's on the first upper and lower diagonals. Solve Ax busing backslash, and time it using ticand toc. Hint: Using the diag command can help here. (b) Repeat the process, but using the sparse matrix format for A. You can do this inefficiently using the sparse command to turn your matrices from part a) 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 docu- tation of spdiags (type "help spdiags" on the command line). Is there a ing difference between solving sparse and full matrices using backslash? men How much
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started