Ecor 2606 lab 2

1
ECOR 2606 Lab #2 This lab illustrates (in miniature) the entire point of this course. In it you will go through the entire problem solving cycle. Starting with an engineering problem, you will first formulate the problem for solution. If you do this correctly, you will discover that the problem involves root finding. You will then obtain a solution to the problem using an appropriate numerical method (in this case, a bisection search). And, finally, you will of course check your solution by relating it back to the original problem. In the interest of promoting lab attendance (and of ensuring that all students actually tackle the problems by themselves) the problem you will be solving will not be revealed until the start of your lab session. Also each lab section will probably get a different problem. Once you have formulated the problems as a root finding exercise (i.e. a problem of the form f(x) = 0) you are to implement f(x) as a function m-file and then obtain a numerical solution by using function bisect (as contained in the function m file provided). Use bisect twice, once with xtol = 0e-4 and ftol = 0 and once with these values reversed. How far apart are the two solutions obtained? You are to submit i) the function m-file that implements f(x) and ii) a script m-file that calls bisect twice and outputs the values obtained and the difference between them. Notes: The interesting part of this lab is formulating the problem for solution. The Matlab part is (or, at least, should be) very straightforward. In total nor more than a dozen Matlab commands are required. Students who are unable to formulate the problem for solution within the available time will be given a function that will allow them to complete the "Matlab" portion of the lab. Preparation: Acquaint yourselves with function bisect. The comments at the start provide user documentation. Practice using function bisect by obtaining a solution to solution to problem A2.1 in the text. As the script m-file that calls bisect twice is going to be the same regardless of what your f(x) turns out to be, this part of the lab can be done in advance.

Transcript of Ecor 2606 lab 2

Page 1: Ecor 2606 lab 2

ECOR 2606 Lab #2

This lab illustrates (in miniature) the entire point of this course. In it you will go through the entire problem solving cycle. Starting with an engineering problem, you will first formulate the problem for solution. If you do this correctly, you will discover that the problem involves root finding. You will then obtain a solution to the problem using an appropriate numerical method (in this case, a bisection search). And, finally, you will of course check your solution by relating it back to the original problem.

In the interest of promoting lab attendance (and of ensuring that all students actually tackle the problems by themselves) the problem you will be solving will not be revealed until the start of your lab session. Also each lab section will probably get a different problem.

Once you have formulated the problems as a root finding exercise (i.e. a problem of the form f(x) = 0) you are to implement f(x) as a function m-file and then obtain a numerical solution by using function bisect (as contained in the function m file provided). Use bisect twice, once with xtol = 0e-4 and ftol = 0 and once with these values reversed. How far apart are the two solutions obtained?

You are to submit i) the function m-file that implements f(x) and ii) a script m-file that calls bisect twice and outputs the values obtained and the difference between them.

Notes:

The interesting part of this lab is formulating the problem for solution. The Matlab part is (or, at least, should be) very straightforward. In total nor more than a dozen Matlab commands are required.

Students who are unable to formulate the problem for solution within the available time will be given a function that will allow them to complete the "Matlab" portion of the lab.

Preparation:

Acquaint yourselves with function bisect. The comments at the start provide user documentation.

Practice using function bisect by obtaining a solution to solution to problem A2.1 in the text.

As the script m-file that calls bisect twice is going to be the same regardless of what your f(x) turns out to be, this part of the lab can be done in advance.