- #1

azdang

- 84

- 0

## Homework Statement

Let A be the nxn matrix with elements a

_{ij}= -1 for i > j, a

_{ii}= a

_{in}= 1, 1 <= i <= n, and zero everywhere else. Let b be a random vector. Solve the linear system Ax = b by Gaussian Elimination with partial pivoting.

Use tril, eye, and ones to generate A,

Generate b with rand.

No loops

## Homework Equations

## The Attempt at a Solution

I'm not sure if this is the correct place to post this, but I figured someone in Computer Science might know MATLAB and be able to help. For one, I am HORRIBLE with MATLAB. I never seem to be able to do it exactly the way my teacher expects it. First off, I'm having trouble generating A. So far, I've used G = eye(n,n) to get a matrix with 1's on the diagonal, and C = tril(-ones(n,n),-1) to get a matrix with -1's where I think they should be. However, I still need a way to get 1's in the last column. Also, I'm not sure how to put these three matrixes together in MATLAB to construct A.

Another thing, I know for G.E.P.P. we need to factor A = PLU. I am assuming for this particular matrix, those will be obvious? Maybe I am wrong. Then, I guess I just have to solve Ly = P

^{T}b and Ux = y.

I'm really just not good with MATLAB, as this is the first class I've ever had to use it for. I've tried reading up on it, and although I generally get the desired outcome, my method never seems to be correct. It would be greatly appreciated if someone could give me some guidance on this problem. Thank you so much.