Question

using python with only using import math and copy no other powerful functions. Write a function...

using python with only using import math and copy no other powerful functions.

Write a function defined as: def GaussSeidel(Aaug, x, Niter = 15):

Purpose: use the Gauss-Seidel method to estimate the solution to a set of N linear equations expressed in matrix form as Ax = b. Both A and b are contained in the function argument – Aaug.

Aaug: an augmented matrix containing [A | b ] having N rows and N+1 columns, where N is the number of equations in the set.

x: a vector (array) contain the values of the initial guess Niter: the number of iterations (new x vectors) to compute

return value: the final new x vector.

Write and call a main() function that uses your GaussSeidel function to estimate and print the solution to the sets of linear equations contained in the following Augmented A-matrices:

MyA = [[4, -1, -1, 3], [-2, -3, 1, 9], [-1, 1, 7, -6]] using initial guesses of all zeros. Perform 22 iterations.

anotherA = [[4, 3, 1, -1, 2], [2, -5, 0, -2, -3], [-3, 3, -6, 1, 5], [0, 1, 4, 8, -2]] using initial guesses of all zeros. Perform 3 iterations.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

GauSied.py 1 def GaussSeidel (Aaug, x, Niter = 15): N = len(x) for n in range (Niter): for i in range (N): res = Aaug[i][N] I

Add a comment
Know the answer?
Add Answer to:
using python with only using import math and copy no other powerful functions. Write a function...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. [12 marks] In the following parts of this question, write a MATLAB code to solve a linear syst...

    1. [12 marks] In the following parts of this question, write a MATLAB code to solve a linear system A b (A is a square nonsingular matrix) using Jacobi and Gauss-Seidel algorithms. Do not use the built-in Matlab functions for solving linear systems (a) Write a Matlab function called Jacobi that consumes a square n x n matrix A, and an n x 1 vector b, and uses the Jacobi technique to solve the system Ax-b, starting with the zero...

  • Test II. ITERATIVE SOLUTION OF SYSTEMS OF LINEAR EQUATIONS Solve the following linear system using Gauss-Seidel...

    Test II. ITERATIVE SOLUTION OF SYSTEMS OF LINEAR EQUATIONS Solve the following linear system using Gauss-Seidel iterative method. Use x = x; = x; =0 as initial guesses. Perform two iterations of the method to find xị, xį and xſ and fill the following table. Show all the calculation steps. 10x, + 2x2 - X3 = 27 -3x, - 6x2 + 2xz = -61.5 X1 + x2 + 5x3 = -21.5

  • in MATLAB 3. Write a function called gauss_seidel that inputs an n x n matrix, A,...

    in MATLAB 3. Write a function called gauss_seidel that inputs an n x n matrix, A, a column vector, b, an initial guess xo), an error tolerance e, and a maximum number of iterations, and output an approximate solution obtained using the Gauss-Seidel method, the error and the number of iterations. The header should look like (x, err, N] = gauss_seidel (A, b, x0, tol, Nmax). Use the method to find approximate solutions to the linear system -2 1 0...

  • Problem 2 (50 points): Estimate x1 and x2 from the following system of equations using 4 iteratio...

    Problem 2 (50 points): Estimate x1 and x2 from the following system of equations using 4 iterations of the Gauss-Seidel method with α,-1 and an initial guess of x,-1 and X2-1. x2-3x, +1.9 0 x,+x-3.0 = 0 Problem 2 (50 points): Estimate x1 and x2 from the following system of equations using 4 iterations of the Gauss-Seidel method with α,-1 and an initial guess of x,-1 and X2-1. x2-3x, +1.9 0 x,+x-3.0 = 0

  • [-230; -1-2 3; 01-21 *X [160 -40 -160]AT Compute vector X using the following methods a) Jacobi m...

    [-230; -1-2 3; 01-21 *X [160 -40 -160]AT Compute vector X using the following methods a) Jacobi method; up to 12 iterations b) Forward Gauss Seidel method; up to 12 iterations c) Symmetric Gauss Seidel method; up to 12 iterations (6 forward and 6 backward iterations) You can use MATLAB to report the final results. However, it is required to calculate at least 3 iterations by hand. You are also expected to compute the spectral radius of the decisive matrix...

  • 3 Linear systems 18. Solve the linear system of equations using the Naive Gauss elimination metho...

    3 Linear systems 18. Solve the linear system of equations using the Naive Gauss elimination method x,+x: + x) = 1 +2x, +4x1 x 19. Solve the linear system of equations using the Gauss elimination method with partial pivoting 12x1 +10x2-7x3=15 6x, + 5x2 + 3x3 =14 24x,-x2 + 5x, = 28 20. Find the LU decomposition for the following system of linear equations 6x, +2x, +2, 2 21. Find an approximate solution for the following linear system of equations...

  • Solve b and c only a) i. A numcrical scheme is known to perform best if...

    Solve b and c only a) i. A numcrical scheme is known to perform best if the height of the uniform subinterval is small enough in the interval (0.2]. The equation that gives the height h of the uniform subinterval is given by f(h) = 3 +h-1=0 Use the fixed point method of finding roots of equations to find the height h for which the scheme performs best. Conduct only four (4) iterations. 6 Marks ii. find algebraically all the...

  • I am new to Matlab so details would be appreciated! Use Matlab or any other Language...

    I am new to Matlab so details would be appreciated! Use Matlab or any other Language /Tool to implement the project work Algorithm for Gauss-Seidel Method to solve the linear (n x n) system Ax = b in matrix form is given by x(0) = initial vector x(4+1) = D-1 (b – Lx(k+1) – Ux(k)), k = 0, 1, 2, ...... where A = L+D+U. Here L, D, U are respectively lower, diag- onal and upper matrices constructed from A....

  • Tutorial 4. Linear systems of algebraic equations 2 October, 4-5 pm in FN2 (Q1) Consider this linear system of equation...

    Tutorial 4. Linear systems of algebraic equations 2 October, 4-5 pm in FN2 (Q1) Consider this linear system of equations a. 1 p -2 0 0 0 1 0 q 0 4 2r -2 0 -1 0 4s Order the four equations such that the system of equations can be solved efficiently by Gauss elimination b. Solve the system by Gauss elimination (Q2) -1] 6 Given the linear system of equations A5 with [A| solve for i 10 and by...

  • Could someone explain these four promblems on matlab and if you do, could you write what...

    Could someone explain these four promblems on matlab and if you do, could you write what you wrote on matlab I.e. on the command window or script. Also if you have written anything by hand can you write neatly. Also an explain of how you did it would be greatly appreciated. 1] 5 points) Write the following set of equations in Matrix form and use Matlab to find the solution. 50 -5x3-6x2 2x2 + 7x3-30 x1-7x3-50-3x2 + 5x1 [2] (10...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT