Possibly, you have trouble getting the level right, because it might feel like restating the obvious to you, if you think of me as the intended reader. Rather visualize as reader a fellow student, who has missed class several times. That is, you may assume that your reader has the assignment as well as the textbook available to him or her. However, you may not assume that he or she has any lecture notes or hints from any source available. Given these assumptions, you must provide a report that is sufficiently detailed so that a reader of your report has sufficient information to reproduce your results.
Let me be clear about some aspects of this description: While you are required to include the actual source code of all code used as appendix, only the key part of your code needs to be described in detail, i.e., the algorithm that we are studying in the particular assignment. The code should be well-written in structure and show helpful short comments to find everything, but I will usually only look at it to try to help you fix some bug, if I find your results in error; this is not a programming course. Remember that your description should be sufficient to understand what you did without actually reading the listing of your code. I usually find that it pays to rewrite the mathematical equations in such a way that it becomes easy to write a code that resembles them. Then, it is also very easy to describe the code, in particular if you choose variable names that resemble the mathematical variables.
Example: We wish to compute the definite integral of f(x)
from a to b. The composite trapezoidal rule is used to
approximate the integral, as given in (5.1.5) on page 253 of Atkinson.
The Matlab function trap.m
was programmed to implement
the rule. It accepts as input a function handle fname
for
f(x), double-precision numbers a
and b
for a and b, and a positive integer n
for the number of subintervals. It returns the numerical integral
approximation In
. Matlab's feval
function is
used to evaluate f(x) at all points x needed.
Then the sum
function is used to perform the summation
in (5.1.5). The code was run on a Linux-PC using Matlab 6.1 (R12.1).
Example: The trapezoidal rule was applied to f(x) = x sin(x) on [a, b] = [0, 1]. The table shows results for n = 2k with k = 1, 2, 3, ... . Since we can compute the true solution I, the true error En = I - In is computed as well as the ratio Rn of the errors En/2 and En. Each row in the table lists n, the approximation In, the error En, and the ratio Rn. We observe that the error gets smaller as the number of subintervals increases, hence the method appears to converge. More precisely, since the ratio Rn tends to 4, as n gets larger, we can conclude that the method converges with order 2, similar as in Table 5.1 in the textbook and as predicted by Theorem 5.1.
Final note: In my examples above, I was limited by the facts that I needed to be as brief as possible and that I was writing this in HTML. Therefore, no formulas were included in my examples. You may notice how unclear the description to anyone but an expert! Let this serve as a pointer: Do not be too brief, and include as many formulas as necessary to be clear!
On grading: Preparing the report is an integral part of the assignment. Complete and correct computer results will never count more than half of the score for the problem. When grading the reports, I will be guided by the questions: ``Are all pertinent questions about the performance of the numerical method addressed?'' and ``Based on the information given, can I reproduce the results?''