Question: Python-- As we discussed in the class, the NumPy package provides a function for solving linear systems. The numpy.linalg.solve function accepts two arguments; first, the

Python--

As we discussed in the class, the NumPy package provides a function for solving linear systems. The numpy.linalg.solve function accepts two arguments; first, the array of coefficients, and second, the array of right hand-side values. Then, the function returns an array for the solution. One requirement for the coefficients array is that it must be a square array (its dimension sizes should be equal, e.g., 2 2 or 3 3). This implies that number of unknowns and equations must be equal. However, there are certain situations where we need to solve linear systems with greater number of unknowns than equations. One approach to solve such systems is to set enough number of unknowns equal to zero so that we again are left with equal number of unknowns and equations. Program a function called solve that accepts three arguments. First, a coefficients array, second, a right-hand side values array, and third, a list of column indices for which the associated unknowns should be set equal to zero. The function should return the complete solution to the linear system with 0s for the zeroed columns in the proper index. Returned values should have at most 2 decimals places. For example, calling a, b, [1, 3] with the following definitions for a and b, should return [-3.12 0. 2.16 0. -1.94 3.88]. a = np.linspace(1, 14, 24) a.shape = (4, 6) b = np.linspace(10, 20, 4)

Hint: To add/delete rows or columns to/from an array, you should use numpy.insert and numpy.delete functions. You can find more about these functions here: https://docs. scipy.org/doc/numpy-1.15.0/reference/generated/numpy.insert.html and https:// docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.delete.html

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!