chbe2120fall2010hw3

chbe2120fall2010hw3 - ChBE 2120 Homework 3 Due: Friday,...

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

View Full Document Right Arrow Icon
ChBE 2120 Homework 3 Due: Friday, September 10 at 8:05 AM Part 1 : Modify your Gauss elimination function from Homework 2 to include partial pivoting. Rename this function mygehw3_yourGtAccountId in the first line of the function and in the file name. Instead of returning an error in forward elimination if the denominator is approximately zero, keep the same check and if statement, but put partial pivoting inside the if statement. If the if statement evaluates to be true, then swap the equation in the current row i with a row below it (not above since you’ve already finished with those rows). Don’t forget to also swap the elements in the vector b . You must check that the row you are swapping with does not have the same divide-by-zero problem as the original row. If it does, then you must try swapping with a different row below. A good way to do this is to compute the absolute value of each element a(j,k) for each j below the diagonal. Pick the one that has the largest absolute value, and then swap that row with row i . You can accomplish this using the max command, for example something like: [Y,I] = max(abs(a(k+1:n,k))). (Try typing help max .) You should consider carefully what the value of I represents in this situation and how you should use it. Whenever you are writing a new piece of code like this, it is an excellent idea to test it on several simple examples. You do not need to turn in any work from these examples, but using this approach will speed up your overall progress. Also, when in doubt, have Matlab display the output of individual steps so you can see what went wrong. Be sure that your code is commented throughout, to describe the variables and the steps in the code. Part 2
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

chbe2120fall2010hw3 - ChBE 2120 Homework 3 Due: Friday,...

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

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