Question: Python v3.9 please! I need help with this question.. i have the answer but not sure how to include the pivoting to get the right

Python v3.9 please! I need help with this question.. i have the answer but not sure how to include the pivoting to get the right answer.  Python v3.9 please! I need help with this question.. i have
gausselim.py example:
the answer but not sure how to include the pivoting to get
eq. (6.17):
the right answer. gausselim.py example: eq. (6.17): Exercise 6.2: a) Modify the

Exercise 6.2: a) Modify the program gausselim.py in Example 6.1 to incorporate partial pivot- ing (or you can write your own program from scratch if you prefer). Run your program and demonstrate that it gives the same answers as the original program when applied to Eq. (6.1). b) Modify the program to solve the equations in (6.17) and show that it can find the solution to these as well, even though Gaussian elimination without pivoting Answer: 61.619,-0.424, -1.238 1.3317 fails. don't do it wlo pivoting from numpy import array, empty A = array([[ 2, 1, 4, 1], [ 3, 4, -1, -1], [1, -4, 1, 5], [2, -2, 1, 3 ]], float) array([ -4, 3, 9, 7 ],float) N = len(v) V = # Gaussian elimination for m in range(N): # Divide by the diagonal element div = A[m,m] A[m, :] /= div v[m] /= div # Now subtract from the lower rows for i in range (m+1,N): mult = A[i,m] A[i, :] -= mult*A [m, :] v[i] -= mult*v [m] # Backsubstitution x = empty(N,float) for m in range (N-1,-1,-1): = for i in range (m+1,N): A[m,i] *x[i] print(x) 0 1 4 1 3 4 -1 -1 1 -4 1 5 2 -2 1 3 -4 3 9 7 (6.17) Exercise 6.2: a) Modify the program gausselim.py in Example 6.1 to incorporate partial pivot- ing (or you can write your own program from scratch if you prefer). Run your program and demonstrate that it gives the same answers as the original program when applied to Eq. (6.1). b) Modify the program to solve the equations in (6.17) and show that it can find the solution to these as well, even though Gaussian elimination without pivoting Answer: 61.619,-0.424, -1.238 1.3317 fails. don't do it wlo pivoting from numpy import array, empty A = array([[ 2, 1, 4, 1], [ 3, 4, -1, -1], [1, -4, 1, 5], [2, -2, 1, 3 ]], float) array([ -4, 3, 9, 7 ],float) N = len(v) V = # Gaussian elimination for m in range(N): # Divide by the diagonal element div = A[m,m] A[m, :] /= div v[m] /= div # Now subtract from the lower rows for i in range (m+1,N): mult = A[i,m] A[i, :] -= mult*A [m, :] v[i] -= mult*v [m] # Backsubstitution x = empty(N,float) for m in range (N-1,-1,-1): = for i in range (m+1,N): A[m,i] *x[i] print(x) 0 1 4 1 3 4 -1 -1 1 -4 1 5 2 -2 1 3 -4 3 9 7 (6.17)

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!