{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# lab3 - CS240 Lab 3 Numerical Analysis Project Goal To solve...

This preview shows pages 1–3. Sign up to view the full content.

CS240 Lab 3 Numerical Analysis Project Goal: To solve linear systems and find roots of complicated functions. It introduces you to the area of numerical analysis. Topics covered: Function calls, loops, selection statements, local variables, standard input, command line arguments, basic printf, two dimensional arrays, solving linear systems, finding roots Task 0: Download the Initial Source Files Download the file lab3-src.tar and untar it by typing the command. tar -xvf lab3-src.tar The directory lab3-src contains the initial sources as well as the script testall that will test all your programs. To build your programs type "make" inside the directory lab3- src . Make sure you compile and test your programs in lore.cs.purdue.edu. Task 1: Gaussian-Jordan Elimination with Partial Pivoting Write a program that uses the Gauss-Jordan method to solve a linear system, i.e. given a matrix A and a vector b, find x such that Ax=b. For example, the system of linear equations x 1 + 2x 2 + 3x 3 = 6 4x 1 + 5x 2 + 6x 3 = 15 7x 1 + 8x 2 + 10x 3 = 25 can be written as Ax=b in the following way. | 1 2 3 | |x 1 | | 6 | | 4 5 6 | |x 2 |= | 15 | | 7 8 10 | |x 3 | | 25 |

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Furthermore, we can write this as what's referred to as an augmented matrix. | 1 2 3 6 | | 4 5 6 15 | | 7 8 10 25 | We then solve by repeatedly performing elementary row operations where row k of the matrix is replaced by row k + scalar * row i ; i and k are arbitrary rows. The goal is to reduce the matrix to the following form | 1 0 0 x1 | | 0 1 0 x2 | | 0 0 1 x3 | The algorithm for doing this is as follows: for each row r[i] of the matrix (i from 1 to n) replace r[i] with r[i] / r[i][i] // r[i][i] is
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern