Advertisement
ogiorgil

backward_substitution()

Oct 9th, 2022
1,152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.25 KB | None | 0 0
  1. function x = backward_substitution(U, b)
  2.   n = length(b);
  3.   x = zeros(n, 1);
  4.   x(n) = b(n)/U(n, n);
  5.   for i = n-1:-1:1
  6.     sum = 0;
  7.     for j = i+1:n
  8.       sum = sum + U(i, j) * x(j);
  9.     endfor
  10.     x(i) = (b(i)-sum)/U(i, i);
  11.   endfor
  12. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement