lab3 - CS240 Lab 3 Numerical Analysis Project Goal: To...

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

View Full Document Right Arrow Icon
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 |
Background image of page 1

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

View Full DocumentRight Arrow Icon
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)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

lab3 - CS240 Lab 3 Numerical Analysis Project Goal: To...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online