Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code below gives the algorithm for Gaussian Elimination with scaled partial pivoting. Below the code, summarize what each block in the code is doing.

image text in transcribed

The code below gives the algorithm for Gaussian Elimination with scaled partial pivoting. Below the code, summarize what each block in the code is doing. def GESPP(A,b): n=len(A) # number of rows of A m=len(A[1]) # number of cols of A 1=[@]*n S=[@]*n ###### Block 1 ##### for i in range(n): 1[i]=i smax = for j in range(n): smax=max(smax, abs (A[i][5])) S[i]=smax ###### Block 2 ##### for kin range(n-1): max=0 for i in range(k,n): r = abs(A[1[1]][k]/[1[i]]) if r>rmax: max=r j=i 1[k],[5]=1[3], 1[k] for i in range(k+1, n): xmult = A[1[1]][k]/A[1[k]][k] #A[1[i]][K]=xmult for j in range(k+1,n): A[1[i]][j]=A[1[i]][j]-(xmult)*A[1[k]][j] b[1[i]]=b[1[1]]-(mult)* b[1[k]] ###### Block 3 ##### b[1[n-1]]=b[1[n-1]]/A[1[n-1]][n-1] for i in range(n-2,-1,-1): sum=b[1[1]] for j in range (i+1,n): sum=sum-A[1[1]][j]*b[1[i]] b[1[i]]=sum/A[1[i]][i] **#### Block 4 ##### X=[@]*n for i in range(n): x[i]=b[1[i]] print(x) Below, summarize what each block of the code above is doing. Block 1: Block 2: Block 3: Block 4: The code below gives the algorithm for Gaussian Elimination with scaled partial pivoting. Below the code, summarize what each block in the code is doing. def GESPP(A,b): n=len(A) # number of rows of A m=len(A[1]) # number of cols of A 1=[@]*n S=[@]*n ###### Block 1 ##### for i in range(n): 1[i]=i smax = for j in range(n): smax=max(smax, abs (A[i][5])) S[i]=smax ###### Block 2 ##### for kin range(n-1): max=0 for i in range(k,n): r = abs(A[1[1]][k]/[1[i]]) if r>rmax: max=r j=i 1[k],[5]=1[3], 1[k] for i in range(k+1, n): xmult = A[1[1]][k]/A[1[k]][k] #A[1[i]][K]=xmult for j in range(k+1,n): A[1[i]][j]=A[1[i]][j]-(xmult)*A[1[k]][j] b[1[i]]=b[1[1]]-(mult)* b[1[k]] ###### Block 3 ##### b[1[n-1]]=b[1[n-1]]/A[1[n-1]][n-1] for i in range(n-2,-1,-1): sum=b[1[1]] for j in range (i+1,n): sum=sum-A[1[1]][j]*b[1[i]] b[1[i]]=sum/A[1[i]][i] **#### Block 4 ##### X=[@]*n for i in range(n): x[i]=b[1[i]] print(x) Below, summarize what each block of the code above is doing. Block 1: Block 2: Block 3: Block 4

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