Fall 2012 - Homework 5: Che 3E04 - Process Model Formulation and Solution
Fall 2012 - Homework 5: Che 3E04 - Process Model Formulation and Solution
OBJECTIVES
SUBMISSION
The method of submission of your answer for each question or part of question will vary. Typically,
anything that can be checked by computer will be submitted to Avenue to Learn, and anything
which must be viewed by humans will be submitted in hardcopy.
[A2LQuiz] - This symbol means to submit your answer to the online quiz on Avenue to Learn
[A2LDropBox] - This symbol means to submit your answer to the drop box on Avenue to Learn
Always have all names and student numbers on any printed out / hardcopies.
This assignment will be different than the previous. Instead of earning points for submitting the
correct answers to the questions, each student must present the solutions to one of the
instructors orally. This means that each of you, individually, must make a 15 minute appointment
for Tuesday Dec 4 [there are no classes that day so there are no excuses – MSAFs will result in
rescheduled appointments]. You will meet with one of the TAs or the professor. During this time,
you will present your code and your written solutions to the instructor, and you will earn points
based on your demonstrated knowledge of the material.
In general, we will be asking critical questions along the way to probe your knowledge, but also to
help you when you get stuck. For example, if you get something wrong, we may be able to ask the
questions in the right way such that you figure out the correct answer on the spot. In fact, it is
possible to get 100% on this assignment even though you have not completed all the questions
because if we judge that, in our opinion, you have complete mastery of how to solve the problem
and know what the outcome would be, then you would earn the points.
1|Page
There are a lot of good things that can come from this. For example, you will get immediate
feedback from the instructors on the key places where you need to improve in order to get ready
for the final exam. Also, sometimes there are just minor tweaks that may make your code work
perfectly that we may be able to get you to correct during the 15 minute oral exam and then thus
earn points.
What the problem is asking you to do. That is, can you explain the problem [both the details
and the point of the problem] to us?
The fundamental theory that we’re applying in order to solve the problem. That is, can you
explain the equations we are using, why we are using them, why they will work, and other
relevant information?
A general solution strategy for how the problem is solved. I.e., present the algorithm to us.
For example, perhaps you should be able to sketch how it works.
The details of the implementation (matlab code) which you used. That is, you should know
each line of it and be able to answer questions about what happens if we change this or that.
The instructors will all have a set of criteria which the student must meet, but they are allowed to
ask whatever questions they need to help get you there. In other words, it’s personal help.
RULES
You must sign up for a time slot. We’re open pretty much all day Dec 4, and there are three
spots per time block. First come first served.
You have 15 minutes to present your case. STAND AND DELIVER. There will be a
whiteboard.
We don’t want powerpoint or rehearsed talks. Just answer our questions.
If you are late, you simply have less minutes. If you miss it, too bad.
You still must submit the hardcopy in class and the Matlab code to the A2L Dropbox
Each group member may bring in photocopies of the hardcopy submission and printouts of
the matlab code. NOTHING ELSE.
We’ll open up your submitted .m files use those on our computers.
You have to submit a hardcopy and code to be eligible for an oral exam and thus any chance
at points.
1. Go to: http://doodle.com/zs87tr7qyf52q35u
2. Type your name in the box that says "Your name"
3. Select an available time slot
4. IMPORTANT: scroll all the way to the right and click "save"
You should see a screen that says "Thanks, your choices have been submitted"
2|Page
QUESTIONS
In this assignment, you will write a program in MATLAB which uses trapezoid integration,
Richardson’s extrapolation, and a step-size adjustment mechanism to create a robust integration
program which maximizes accuracy while minimizing the number of function evaluations. The
program should be applicable to any arbitrary scalar function f(x) and only require the tolerance (ε)
and domain limits (xmin and xmax) to be specified as inputs. This is very close to a “professional”
numerical integrator which forms the heart of just about any piece of numerical software used
throughout industry.
To do this, we can use the algorithm derived in class and break the pieces up into baby steps. To
start with, we will use the following test function:
Q1) Write the above function in an .m file so that given x as an input it returns f(x). Hint, it pretty
much should be only two lines long. This just makes it easy to make function calls to it, and lets us
swap out for new functions very easily by making only one change.
Q2) Write a new matlab function which will approximate the following integral…
∫ ( ) (eq 2)
…using one big trapezoid approximation. Note that if b and a are close together, this will be a good
approximation for the area under the curve. As a hint, this function should only require about two
lines of code. The function should take a and b as parameters (the stuff you pass into the function).
Q3) Now, write a new matlab function which uses Richardson extrapolation to make a higher-order
approximation of eq 2. As discussed in class:
3|Page
a. Call this same function recursively using the left and right halves of the integral.
This will effectively half the stepsize in the region a to b.
5. HINTS:
a. This function should accept a, b, and the tolerance as a parameter.
b. My solution is ten lines long to give you an idea of scale. Yours can be longer or
shorter as long as it works.
c. You will use recursion as discussed in class.
d. It might help you to debug by outputting the values of a, b, and the integral to the
command terminal each time this function runs. For example, consider adding the
line:
fprintf('Now integrating from %g to %g\n', a, b);
Similarly, maybe you want to add similar print statements where you either accept
or break the integral down into parts.
Q4) Finally, write a program which calls your function in Q3 to integrate of eq1 from 1 to 10 with a
tolerance of 0.2.
Q5) Estimate the “exact” integral of eq1 from 1 to 10 using matlab’s built in quad function. As an
example, if the function you made in Q1 was called Q1.m, you could use the command:
The quad function does essentially the same algorithm that you are using in this assignment, except
that it uses Simpson’s rules instead of trapezoids. Note that to use quad, your Q1 function needs
accept vectors, so put dots before your operators: log(x.^2./(1+x)) + sin(cos(x.^2))
Q6) Report the estimated error between your result and the “professional” version using the Q5
result as your estimate for the “actual” result. [ONPaper]
Q7) Modify your program to make a log-log plot the estimated error of your integral as the
tolerance changes from 10-1 to 10-7. Submit this plot and all code to Avenue to Learn and in hard
copy. [A2LDropBox] [ONPaper]
Note, you can use the loglog command in matlab just like you would use the plot
command to make a log-log plot.
Note an easy way to get points relative to a log-log plot from 10-1 to 10-7 is to use the
command logspace(-1, -7). This will create a vector of points from 10-1 to 10-7.
Q8) Now, go back and modify your code so that instead of trapezoids, Simpsons 1/3 rule is used.
Repeat question Q7 and add the estimated error using Simpsons to the plot (so you can see
simpsons and trapezoids both). Note that Richardson’s Extrapolation for Simpsons is not the same,
its:
4|Page