Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this is a matlab question Q1a The Thomas tri-diagonal algorithm uses a direct solve to find solutions of the linear system Ax-b where the matrix
this is a matlab question
Q1a The Thomas tri-diagonal algorithm uses a direct solve to find solutions of the linear system Ax-b where the matrix A has tridiagonal form (Workshop 2). The method is essentially the same as Gaussian elimination, but because most of the matrix entries are zero, the method is far more efficient. i) Write a MATLAB function (Thomas) that implements the Thomas tri-diagonal algorithm. The function header MUST be function [x] Thomas ( a,b,c,r) = where x is the solution, a,b,c are the coefficients of the tridiagonal matrix A (a is lower diagonal, b the central diagonal and c the upper diagonal) and r is the right hand side vector. (NOTE: The equation for variable x is ai-i + bix cx , thus a(0)0 and c(n) 0); ii) You are provided with a MATLAB function set-T(N) that sets the coefficients a,b,c and the rhs vector r you should use when running your code. You set the vectors a,b,c,r for an NxN system by choosing an appropriate N and using [a,b,c,rl-set T(N) Modify the m-file Lab_01 01a.m and calculate the solution x for tridiagonal systems defined by set_T(N) with N-500,1000,2000,4000. Use the MATLAB functions tic and toc to time how long it takes to find x for each different N. ii) For each N, print to the command window a single line which prints the values of N and the time taken to converge) with suitable description - i.e. don't just write 2 numbers). Plot the run times as a function of N in a properly labeled figure using red circles and linear coordinates. iv) Looking at the plot and ignoring the first point (i.e. for N-500) do you think there is a clear functional relationship between the run time and the problem dimension N? Write a short statement to the command window to answer this with question and include why you believe your answer is correct. v) How can you determine if you have found the correct answer for x? Write a short paragraph to the command window stating how and then implement this in the code in Lab_01_Q1a.m and demonstrate the answer you find is correct Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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