Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pentadiagonal solver Write a MATLAB function penta below that solves pentadiagonal systems of equations of size n. A pentadiagonal matrix is a banded one with

image text in transcribedimage text in transcribed

Pentadiagonal solver Write a MATLAB function penta below that solves pentadiagonal systems of equations of size n. A pentadiagonal matrix is a banded one with bandwidth = 5 and p = q = 3. Assume that no pivoting is needed, but do not assume that the matrix A is symmetric. Your program should expect as input six vectors: md = main diagonal vector of A (length n) ld = lower diagonal of A (length n - 1) . lld = next lower diagonal of A (length n - 2) ud = upper diagonal of A (length n - - 1) uud = next upper diagonal of A (length n 2) b = right hand side vector (length n) It should calculate and return x = A-'b using a Gaussian elimination variant that required O(n) flops and consumes no additional space as a function of n (i.e., in total 7n storage locations are required). Try your program on the matrix defined by n = 100,000, dj,i+2 = di+2,i = i, di,i+1 = dj+1,i = 2i, and aj,i = 8i, for all i such that the relevant subscripts fall in the range 1 to n. Derive a right hand side vector b = Axexact using Xexact = = (1, 1, ..., 1)? Then solve for x given this b and record || Xexact -x||2 to verify your solver. function [x, md, ud, uud] = penta (md, ld, ud, lld, uud, b) % Solve Ax = b for a pentadiagonal A md = main diagonal vector of A (length n) ld lower diagonal of A (length (n-1)) ild = next lower diagonal of A (length (n-2)) ud upper diagonal of A (length (n-1)) uud = next upper diagonal of A (length (n-2)) b right hand side vector (length n) = end % penta Pentadiagonal solver Write a MATLAB function penta below that solves pentadiagonal systems of equations of size n. A pentadiagonal matrix is a banded one with bandwidth = 5 and p = q = 3. Assume that no pivoting is needed, but do not assume that the matrix A is symmetric. Your program should expect as input six vectors: md = main diagonal vector of A (length n) ld = lower diagonal of A (length n - 1) . lld = next lower diagonal of A (length n - 2) ud = upper diagonal of A (length n - - 1) uud = next upper diagonal of A (length n 2) b = right hand side vector (length n) It should calculate and return x = A-'b using a Gaussian elimination variant that required O(n) flops and consumes no additional space as a function of n (i.e., in total 7n storage locations are required). Try your program on the matrix defined by n = 100,000, dj,i+2 = di+2,i = i, di,i+1 = dj+1,i = 2i, and aj,i = 8i, for all i such that the relevant subscripts fall in the range 1 to n. Derive a right hand side vector b = Axexact using Xexact = = (1, 1, ..., 1)? Then solve for x given this b and record || Xexact -x||2 to verify your solver. function [x, md, ud, uud] = penta (md, ld, ud, lld, uud, b) % Solve Ax = b for a pentadiagonal A md = main diagonal vector of A (length n) ld lower diagonal of A (length (n-1)) ild = next lower diagonal of A (length (n-2)) ud upper diagonal of A (length (n-1)) uud = next upper diagonal of A (length (n-2)) b right hand side vector (length n) = end % penta

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

Recommended Textbook for

Analytical Corporate Finance

Authors: Angelo Corelli

1st Edition

3319395483, 9783319395487

More Books

Students also viewed these Accounting questions

Question

Define Administration and Management

Answered: 1 week ago

Question

Define organisational structure

Answered: 1 week ago

Question

Identify ways to increase your selfesteem.

Answered: 1 week ago