Gaussian elimination in MATLAB

In summary, the conversation discusses a homework assignment that involves experimenting with Gaussian elimination and partial pivoting. The first question can be solved using a calculator or computer, while the second question requires a computer and the third question involves solving a matrix with MATLAB. The conversation also mentions finding the inverse matrix and assessing its quality, as well as solving a matrix with trivial and partial pivoting. The conversation ends with a request for help with implementing these techniques in MATLAB and a recommendation to check the thread list and search the MATLAB website for more information.
  • #1
aznkid310
109
1

Homework Statement



The point of this homework is to experiment with Gaussian elimination, and to
develop an appreciation for partial pivoting. Questions 1 & 2 can be done with a
calculator (though a computer is preferred). Question 3 requires a computer – you
do not necessarily have to write any programs: C++ examples are on the class
web page, and Matlab examples are all over the web. Use whatever you like, but
give credit to your sources.
Q1)

[2.0 1:0 1:0 [ x1 [2.0 + 10e-10
1.0 10e-10 10e-10 x2 = -10e-10
1.0 10e-10 10e-10] x3] 10e-10]

Solve this equation for x using partial pivoting. Strive
to achieve the most accurate results possible (e.g., double precision). First obtain
the decomposition
PA = LR
then use this decomposition to determine x with two back substitution steps:
Ly = (Pb)
Rx = y

Q2) The identity matrix I can be thought of as a collection of vectors:
I = (e1e2...en)
where ei is a vector of length n that is zero, except in the ith component which is 1.

If one were to represent the inverse matrix A^-1 as a collection of vectors,
A^-1 = (a1a2...an).

Then the ith column of A^-1 can be determined by solving Aai = ei. Or, using our
LR decomposition, LR(ai )= P(ei). Use this to find the inverse of the matrix in (1)
with P,L,R from partial pivoting. Assess the quality of the result by computing
(A^-1)A.

Q3) For n = 60, solve
Ax = b
where n n matrix A is given by
Ai j =r2n + 1sin2i j2n + 1
i; j = 1 to n;

and where b is given by the n-long vector of ones. With trivial pivoting, and with
partial pivoting, calculate r = b-Ax. Present sqrt(r*r) (aka the L2 norm krk2), which
should be zero with perfect math.

Homework Equations



I was able to do #1 with a calculator and by hand, and I understand the basic ideas of 2 and 3, but I don't know how to implement them in MATLAB.

The Attempt at a Solution



For #1, i get
x = 4
-2
2
 
Last edited:
Physics news on Phys.org

1. What is Gaussian elimination in MATLAB?

Gaussian elimination is a method used in MATLAB to solve systems of linear equations. It involves transforming a matrix into an upper triangular matrix through a series of row operations, making it easier to solve for the unknown variables.

2. How do I use Gaussian elimination in MATLAB?

To use Gaussian elimination in MATLAB, you can use the built-in function "rref" which stands for reduced row echelon form. This function takes a matrix as an input and outputs the reduced row echelon form of that matrix, which can then be used to solve the system of equations.

3. What are the advantages of using Gaussian elimination in MATLAB?

Gaussian elimination in MATLAB is a more efficient and accurate way to solve systems of linear equations compared to manual calculation. It also allows for the use of larger matrices and can handle more complex systems of equations.

4. Can Gaussian elimination in MATLAB handle singular matrices?

No, Gaussian elimination in MATLAB cannot handle singular matrices. This is because a singular matrix does not have an inverse and therefore cannot be transformed into an upper triangular matrix using row operations.

5. Are there any limitations to using Gaussian elimination in MATLAB?

One limitation of Gaussian elimination in MATLAB is that it can only be used for systems of linear equations. It cannot be used for nonlinear systems or for solving differential equations. Additionally, the method may encounter numerical instability for very large or very small numbers in the matrix.

Similar threads

  • Calculus and Beyond Homework Help
Replies
1
Views
644
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
33K
Replies
22
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
18K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
Back
Top