# Project #7725 - Matlab

I need someone to do the four below questions in MatLab

1. In MATLAB, write a function which accepts array A and vector b and returns x, the solution

to Ax = b. The program should also return L and U, the lower and upper arrays from LU

decomposition of A. The MATLAB program should use the Gaussian elimination method,

check for zero pivot variables, and perform row swaps as necessary. The row swaps should be

saved in a permutatation matrix P, which should also be returned. See example 4-3 in the

book for use as a starting point. The function de nition line should be the following:

function [x,L,U,P] = GaussLUP(A,b)

2. In MATLAB, write a function which accepts an array A and vector b and returns x, the

solution to Ax = b. The solution method should use the Jacobi iteration method. Use a

vector of zeros as the rst guess for x. The function should also return k, the number of

iterations required to reach solution convergence. Iterate until the estimated relative error in

x is less than 104

. The function de nition line should be the following:

function [x,k] = Jacobi(A,x)

3. Using the above Jacobi method MATLAB code as a starting point, modify the code to use

the Gauss-Seidel method. The function de nition line should be the following:

function [x,k] = GaussSeidel(A,x).

4. Make a random array A using A = rand(500,500) + 10*eye(500). Make a random vector

b using b = rand(500,1). Write a script which records the time taken to solve for x for each

of the above functions using the tic and toc commands. Report the time taken for each case.

Report the number of iterations required for the iterative methods. Report the relative error

in x for the iterative methods assuming the x from Gaussian elimination as a true solution.

Please submit to Blackboard a neatly formatted PDF writeup for this assignment. In addition to

the PDF, also attach each m- le to the homework submission. Blackboard will allow you to attach

multiple les with one submission

 Subject Mathematics Due By (Pacific Time) 06/14/2013 11:00 am
TutorRating
pallavi

Chat Now!

out of 1971 reviews
amosmm

Chat Now!

out of 766 reviews
PhyzKyd

Chat Now!

out of 1164 reviews
rajdeep77

Chat Now!

out of 721 reviews
sctys

Chat Now!

out of 1600 reviews

Chat Now!

out of 770 reviews
topnotcher

Chat Now!

out of 766 reviews
XXXIAO

Chat Now!

out of 680 reviews