Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the modified version of the function solve by back substitution that accepts a matrix u in row echelon form and a right-hand-side vector b

Write the modified version of the function solve by back substitution that accepts a matrix u in row echelon form and a right-hand-side vector b and returns as output:

- None, if the system has no solution (Hint: This can be determined simply by checking whether the right-hand-side vector has a non-zero entry in any of the all-zero rows of the matrix)

- A solution where all entries corresponding to free variables are 0 (Hint: All other values are then uniquely determined).

example:

>>> u = [[1, 1, 0, 1, 1],

... [0, 0, 1, 0, 1],

... [0, 0, 0, 0, 1],

... [0, 0, 0, 0, 0],

... [0, 0, 0, 0, 0]]

>>> b = [2, 2, 1, 0, 0]

>>> solve_by_back_substitution(u, b)

[1.0, 0.0, 1.0, 0.0, 1.0]

code to be modified:

def solve_by_back_sub(u,b):

n = len(b)

x = n*[0]

for i in range(n-1, -1, -1):

s = sum(x[j] * u[i][j] for j in range(n-1, i, -1))

x[i] = (b[i] - s)/u[i][i]

return x

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions