Question

Problem 1 Consider the linear system of equations Ax = b, where x € R4X1, and A= 120 b = and h= 0.1. [2+d -1 0 0 1 1 -1 2+d -just 1,2,4

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


%&Matlab code for Gauss Siedel Method and Jacobi method clear all close all Loop for table for n iterations -1 2+d]; fprintf( Binitial x and convergence x0=h 2 .*[1;-1;2;-2); conv=10^-6; Jacobi method [x_j, it_j]=Jacobi_method(A,b, x0, conv); fprintf(it-it+1; for i=1:length(b) S=0; for j=1:length(b) if i-=j s=s+A(i, j) *x0()); end end x0(i)=(b(i)-s)/Ali, i); end if it==1000#loop for backward substitution of Gaussian elimination matrix for finding x for ii-ss-1:-1:1 sum=0; for jj=ii+1:ss sum-sum+A0.000545454545454546 0.000181818181818182 A matrix is for d=1 and h=0.1 [ 100.0, -100.0, 0, 01 [ -100.0, 100.0, -100.0, 01 0,%creating A matrix
    d=1; h=0.1;
    A=(1./(h^2)).*[2+d -1 0 0; -1 2+d -1 0; 0 -1 2+d -1; 0 0 -1 2+d];
    fprintf('A matrix is for d=1 and h=0.1\n')
    disp(vpa(A,3))
    %creating B vector
    b=[1;0;0;0];
  
    %Gaussian Elimination
    [x1,B]=gauss_eliminationn(A,b);
    fprintf('Solution using Jacobi method is\n')
    disp(x1')
  
    %LU Decomposition of A
    [L,U]=lu(A);
    fprintf('LU Decomposition of A\n')
    fprintf('L matrix is \n')
    disp(vpa(L,3))
    fprintf('U matrix is \n')
    disp(vpa(U,3))
    %initial x and convergence
    x0=h^2.*[1;-1;2;-2];
    conv=10^-6;
    %Jacobi method
    [x_j,it_j]=Jacobi_method(A,b,x0,conv);
    fprintf('Total iteration is %d and Solution using Jacobi method is\n',it_j)
    disp(x_j)
    %Gauss Siedel method
    [x_g,it_g]=Gauss_method(A,b,x0,conv);
    fprintf('Total iteration is %d and Solution using Gauss method is\n',it_g)
    disp(x_g')
    %exact solution
    x_ext=A\b;
    fprintf('Exact solution is\n')
    disp(x_ext)

Add a comment
Know the answer?
Add Answer to:
just 1,2,4 Problem 1 Consider the linear system of equations Ax = b, where x €...
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
  • Question 1 (10 marks) For a linear system Ax- b with 1 0 -1 A-1 2-1 2 -1 3 b=14 18 and compute by...

    Please do question 5 for me. Thanks Question 1 (10 marks) For a linear system Ax- b with 1 0 -1 A-1 2-1 2 -1 3 b=14 18 and compute by hand the first four iterations with the Jacobi method, using x()0 Hint: for the ease of calculation, keep to rational fractions rather than decimals Question 2 For the same linear system as in Question 1, compute by hand the first three iterations (10 marks) with the Gauss Seidel method,...

  • 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...

  • Consider the linear system 5x1 - 21 + X1 - 22 + x3 = 1 5.22...

    Consider the linear system 5x1 - 21 + X1 - 22 + x3 = 1 5.22 - 23 = 2 22 5 5x3 = 3 (a) Discuss the convergence of the iterative solutions of this system generated by the Jacobi and Gauss-Seidel methods, by considering their iterative matrices. (b) If both methods converge, which one of them converges faster to the exact solution of this system? (c) Starting with the initial approximation x(0) = [0,0,0], find the number of iterations...

  • Question 1 (10 marks) For a linear system Ax b with 1 0-1 A-1 2-1 2-13 and b4 18 compute by hand ...

    Question 1 (10 marks) For a linear system Ax b with 1 0-1 A-1 2-1 2-13 and b4 18 compute by hand the first four iterations with the Jacobi method, usg0 Hint: for the ease of calculation, keep to rational fractions rather than decimals. (10 marks) Question 2 For the same linear svstem as in Question 1. compute by hand the first three iterations with the Gauss Seidel method, us0 Hint: for the ease of calculation, keep to rational fractions...

  • Rearrange the equations to form a strictly diagonally dominant system. Use the Jacobi iterative m...

    Rearrange the equations to form a strictly diagonally dominant system. Use the Jacobi iterative method and Gauss-Seidel methods with an initial vector (0, 0, 0) and 10 iterations to approximate the solution of the system. Solve the system directly and compare your results. X - 8Y - 2Z = 1 X + Y + 5Z = 4 3X - Y +Z = -2

  • 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...

  • 2a. Given a linear system of equations A b with a symmetric positive definite matrix A ERIX4 whic...

    2a. Given a linear system of equations A b with a symmetric positive definite matrix A ERIX4 which has eigenvalues 1, 1/4, 1/9,1/16. Consider the iterative method defined by r(k +1) = r(k)-w(Ax(k)-b). Can you choose w such that method is convergent? If so, what is the best possible w? 2b. Discuss the convergence of the Jacobi method for Ar-b with the tridiagonal matrix -1 3 Does the Jacobi method converge for this matrix? What is the convergence rate 2a....

  • 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...

  • 100 GAUSSIAN ELIMINAONO the system Ax = b (where A is n × n and nonsingular),...

    100 GAUSSIAN ELIMINAONO the system Ax = b (where A is n × n and nonsingular), MATLAB uses Gaussian elimination with partial pivoting to solve the system. If you want to see the LU decomposition, use the MATLAB command lu. Exercise 1.8.10 Use MATLAB to check the LU decomposition obtained in Example 1.8.2 Enter the matrix A, then type [L, U, P] = lu (A) . Once you have L, U, and P, you can put them back together by...

  • [-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...

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