Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
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