Question: HOW TO MODIFY THIS CODE TO WORK FOR PENTADIAGONAL SYSTEMS function y - tridiag( a, b, c, f ) % Solve the n x n

HOW TO MODIFY THIS CODE TO WORK FOR PENTADIAGONAL SYSTEMS

HOW TO MODIFY THIS CODE TO WORK FOR PENTADIAGONAL SYSTEMS function y

function y - tridiag( a, b, c, f ) % Solve the n x n tridiagonal system for y: b (2) a(2) c (2) 1 Y(2) (2) b(3) a (3) c(3) b (n-1) a(n-1) c (n-1) y(n-1) ] [ f(n-1) ] b (n) a (n) Y(n) (n) f must be a vector (row or column) of length n % a, b, c must be vectors of length n (note that b(1) and c (n) are not used) % some additional information is at the end of the file n = length ( f ) ; v = zeros ( n, 1) ; w = a(1); for i-2:n v(i-1) -c(i-1)/wi w = a(i) -b(i)ty(1-1 ) ; end for j-n-1:-1:1 yj) y(j) - v(j)*y(j+1); end function y - tridiag( a, b, c, f ) % Solve the n x n tridiagonal system for y: b (2) a(2) c (2) 1 Y(2) (2) b(3) a (3) c(3) b (n-1) a(n-1) c (n-1) y(n-1) ] [ f(n-1) ] b (n) a (n) Y(n) (n) f must be a vector (row or column) of length n % a, b, c must be vectors of length n (note that b(1) and c (n) are not used) % some additional information is at the end of the file n = length ( f ) ; v = zeros ( n, 1) ; w = a(1); for i-2:n v(i-1) -c(i-1)/wi w = a(i) -b(i)ty(1-1 ) ; end for j-n-1:-1:1 yj) y(j) - v(j)*y(j+1); end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!