Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python - The systemsolvers.py file contains an unfinished function with the following first line: def scaled_partial_pivoting (A,b,n,c) : The input A is of type

image text in transcribedimage text in transcribed

Using Python

- The systemsolvers.py file contains an unfinished function with the following first line: def scaled_partial_pivoting (A,b,n,c) : The input A is of type numpy . ndarray and has shape (n,n) and represents the square matrix A. The input b is of type numpy. ndarray and has shape (n,1) and represents the column vector b. The input n is an integer such that n2. The input c is an integer such that 1cn1, and it is used to (prematurely) stop the forward elimination with scaled partial pivoting algorithm; see details below. - Complete the scaled_partial_pivoting function so that the output M is of type numpy.ndarray and has shape (n,n+1), and represents the augmented matrix arrived at by starting from the augmented matrix [Ab] and performing forward elimination with scaled partial pivoting (as described in the Linear Systems: Direct Methods II slides) until all of the entries below the main diagonal in the first c columns are 0 . The scaled_partial_pivoting function should call the find_max function in order to do this. Hint: Note that M[[i,p],:]=M[[p,i],:] can be used to interchange the row M[i,:] and the row M[p,:]. Also note that s[[i,p]]=s[[p,i]] can be used to interchange s [i] and s[p]. - The systemsolvers.py file contains an unfinished function with the following first line: def spp_solve (A,b,n) : The input A is of type numpy .ndarray and has shape (n,n) and represents the matrix A. The input b is of type numpy . ndarray and has shape (n,1) and represents the vector b. The input n is an integer such that n2. - Complete the spp_solve function so that the output x is of type numpy. ndarray and has shape (n,1), and represents the solution x to Ax=b computed using Gaussian elimination with scaled partial pivoting. In order to do this, the spp_solve function should call the scaled_partial_pivoting function and the backward_substitution function. Note that a completed version of the backward_substitution function is in the warmup_solution module that is imported in systemsolvers. py. - Test your scaled_partial_pivoting and spp_solve functions by running the main.py file. The output from the scaled_partial_pivoting function obtained hu runnine the main nu file shnuld ha. The output from the spp_solve function obtained by running the main.py file Assessment When submitting your coursework, you will only be asked to upload your systemsolvers.py file. Marks can be obtained for your scaled_partial_pivoting function definition for generating the required output, for certain set(s) of inputs for {A,b,n,c}. The correctness of the following will be checked: - The type of output M - The np. shape of output M - The values of output M. Marks can be obtained for your spp_solve function definition for generating the required output, for certain set(s) of inputs for {A,b,n}. The correctness of the following will be checked: - The type of output x - The np. shape of output x - The values of output x. Note that in marking your work, different input(s) may be used

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

What is the relationship between humans?

Answered: 1 week ago

Question

What is the orientation toward time?

Answered: 1 week ago