Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Gaussian elimination with scaled partial pivoting Let ARnn and bRn. Suppose that A is such that there exists a unique solution xRn to Ax=b and
Gaussian elimination with scaled partial pivoting Let ARnn and bRn. Suppose that A is such that there exists a unique solution xRn to Ax=b and that forward elimination with scaled partial pivoting can be performed to arrive at an augmented matrix to which backward substitution can be applied to find x. 2 A pseudocode algorithm for finding the smallest positive integer p such that vp=maxj{1,2,,n}vj is the following: Set m=0 Set p=0 For j=1 to n do If vj>m Set m=vj Set p=j End If End do - Open the file systemsolvers.py. The systemsolvers.py file contains an unfinished function with the following first line: def find_max (M,s,n,i) : The input M is of type numpy . ndarray and has shape (n,n+1). The input s is of type numpy. ndarray and has shape (n,)andissuchthatallofitselementsare positive. The input n is an integer such that n2. The input i is a nonnegative integer such that in2. - Complete the find_max function so that the output p is of type int and is the smallest integer such that pi and s[p]M[p,i]=maxj{i,i+1,,n1}s[j]M[j,i]. Hint: To calculate the absolute value, one can use the command abs, np.abs or np.absolute; see numpy.org/doc. - Test your find_max function by running the main.py file. The output from the find_max function obtained by running the main.py file should be p=1 (because s[j]M[j,0] is 0.2,0.5 and 0.5, for j=0,1,2, respectively). Assessment When submitting your coursework, you will only be asked to upload your systemsolvers. py file. Marks can be obtained for your find_max function definition for generating the required output, for certain set(s) of inputs for {M,s,n,i}. The correctness of the following will be checked: - The type of output p - The value of output p
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started