Question: Numpy and Python. a) Implement back substitution in Python, using Numpy. Use simple numpy function, f.ex. numpy.dot. Solve for Rx = b, where R =

Numpy and Python.

a) Implement back substitution in Python, using Numpy. Use simple numpy function, f.ex. numpy.dot. Solve for Rx = b, where R = numpy.array([[1,4,1], [0,6,4], [0,0,2]]) is the upper triangle matrix and b = numpy.array([3,2,1]) is the lower triangle matrix.

Numpy and Python. a) Implement back substitution in Python, using Numpy. Use

Use the following code:

def backsub(R,b): """ back substitution input: n x n upper triangle matrix R (treated as a normal matrix) n-vector b output: The solution x for Rx=b """ n=R.shape[0] x=np.zeros(n) # enter code here # ... return x

b) Implement an algorithm that solves the linear square simultaneous equation Ax = b with QR decomposition and back substitution. Use the following code and the qr and backsub functions from a), as well as Numpy. Solve the simulataneous equation Ax = b, with A = numpy.array([1,2,-1],[-1,1,1],[1,-4,1]]) and b = numpy.array([1,2,3]) with your code.

simple numpy function, f.ex. numpy.dot. Solve for Rx = b, where R

Begin with this code:

def linsolve(A,b): """ Solves Ax=b""" # enter code here # ... return x

Algorithm 11.1 BACK SUBSTITUTION given an n x n upper triangular matrix R with nonzero diagonal entries, and an n-vector b. Fori,1

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!