2.29: Numerical Fluid Mechanics
Problem Set 2
MASSACHUSETTS INSTITUTE OF TECHNOLOGY
DEPARTMENT OF MECHANICAL ENGINEERING
CAMBRIDGE, MASSACHUSETTS 02139
2.29 NUMERICAL FLUID MECHANICS— SPRING 2007
Problem Set 2
Posted 02/25/07, due Thursday 4 p.m. 03/8/07, Focused on Lecture 4 to 7
Problem 2.1 (6% of final grade): Advance your programming skills and review root finding methods
Review MATLAB help about:
•
Function handle
•
eval
•
nargin
•
varargin
•
cell: as a data type
•
switch: as flow control command
•
fprintf
•
lower
Here we want to develop a script as a generalized one dimensional solver. Later you can use it for
next problems. The function that you write should provide the maximum ease of use, as well as the
maximum amount of flexibility and adjustment. To that end and to develop a user friendly program:
•
The function should have default values for everything so that the user can run it with
minimum number of inputs.
•
The input function (to be solved) should be either a function handle or a string (like
‘3*x^35*x+1’).
•
The program should have a nice command line output or plot displaying the gradual
progress of solution.
•
The user should be able to adjust/provide the below options, if necessary. Note that user
should not need to memorize any order for them and option names should not be case
sensitive:
a)
Method: Newton, Secant, BiSection, FalsePosition, Modified False
Position
b)
Initial guess: it can be two numbers for methods like BiSection
c)
Derivative of f (note that you can compute the derivative if user
provides you with a string as solution equation)
d)
Absolute tolerance on x or f
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
2.29: Numerical Fluid Mechanics
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '07
 HenrikSchmidt
 Mechanical Engineering, Numerical Analysis, Numerical Fluid Mechanics

Click to edit the document details