



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Leveque; Class: TIME DEPNDT PROBS; Subject: Applied Mathematics; University: University of Washington - Seattle; Term: Spring 2007;
Typology: Assignments
1 / 6
This page cannot be seen from the preview
Don't miss anything!




AMath 586 Sample Homework Spring, 2007
Many of the homework problems in this course will have a large computational component. I hope that these problems will achieve several goals, allowing you to obtain
In particular, it is not enough to simply get your program running and hand in a bunch of output. Typically you will be required to make some creative choices in deciding what to run and do some analysis of your results in order to understand what is going on, or at least to check that the method is working as expected. You should also write up your analysis and conclusions clearly and concisely. I suggest that you consider using a format along the following lines, as modified to fit the particular problem.
Tables of errors are appropriate for checking the convergence rate, but tables with more than a dozen numbers or so become unwieldy. In particular, if the error is a function, then you should print out some appropriate norm of the error, not the error at every point. A graph of the error vs. some parameter (step size, iteration number) may also be useful. Often a log-log plot is best for this.
Part of the problem is to choose what output to present. If you have to run 100 cases in order to understand what is going on, please don’t give me the output of all 100! Once you understand things clearly, you should be able to select a small set of cases that illustrate the main points, different types of behavior, critical cases, or whatever. Present results that illustrate and complement your analysis and conclusions.
Typesetting. Although not required, I suggest that you use latex to type up your solutions. This is the standard math typesetting system used by most researchers and journals in applied mathematics so it’s good to get proficient at using it. I will try to make it easy for you to learn it as we go along if you’re not already familiar with it, by providing some examples of how the sorts of expressions we use in this course are typeset. The latex source for all the homework assignments will be available from the webpage so you don’t have to retype the exercises, just copy these into your latex file if you want to include the questions along with your solutions. To get started, there are many latex tutorials on the web and many books. You might also want to take a look at the latex source for this handout, available from the class webpage. Note: the figures were made using matlab to first display the figure on the screen and the
print err1.eps
for example, dumps the current screen to an encapsulated postscript file that is read into the latex document using epsfig.
Example. As an example of a reasonable write-up, here is a sample problem and solution. The matlab m-files can be obtained from the class web page.
Compute approximations to u′(¯x) for ¯x = 1 using the approximations
D+u(¯x) =
h
[u(¯x + h) − u(¯x)]
D 0 u(¯x) =
2 h
[u(¯x + h) − u(¯x − h)]
D 3 u(¯x) =
6 h
[2u(¯x + h) + 3u(¯x) − 6 u(¯x − h) + u(¯x − 2 h)]
for each of the following functions:
u 1 (x) = sin(10x), u 2 (x) = 4x^3 − 12 x^2 + 14x − 4 , u 3 (x) = |x − 1. 001 |^3 /^2.
In each case use several different values of h to approximate the derivative and discuss the behavior of the errors as h is decreased.
Taylor series expansion of the three methods shows that:
D+u(¯x) − u′(¯x) =
hu′′(¯x) +
h^2 u′′′(¯x) + O(h^3 )
D 0 u(¯x) − u′(¯x) =
h^2 u′′′(¯x) + O(h^4 )
D 3 u(¯x) − u′(¯x) =
h^3 u′′′′(¯x) + O(h^4 ).
We expect the methods to be first-order, second-order, and third-order accurate respectively.
Second test function: With this function we obtain the results shown in Figure 2. For very small h the results are again contaminated by roundoff. For larger h we see some unexpected behavior. The approximations D+ and D 0 produce essentially the same results while D 3 looks to be nearly exact. Looking carefully at the truncation errors shows that this is correct, however. The function u 2 satisfies u′′ 2 (1) = 0 so that the leading term in the error for D+ drops out. Also, since u 2 is a polynomial of degree 3, its 4’th derivative and all higher derivatives are zero everywhere, so the error in D 3 should be zero. The fact that it isn’t exactly zero is again a result of the rounding errors that arise in computing D 3 u 2 (1).
h D+ error D_0 error D_3 error
1.0000e-01 4.0000e-02 4.0000e-02 7.5495e- 1.0000e-02 4.0000e-04 4.0000e-04 -1.2879e- 1.0000e-03 4.0000e-06 4.0000e-06 9.6412e- 1.0000e-04 3.9999e-08 4.0008e-08 1.3102e- 1.0000e-05 4.5719e-10 5.0160e-10 1.4633e- 1.0000e-06 -1.4968e-09 -6.0862e-10 -1.6504e- 1.0000e-07 5.6086e-09 -3.2732e-09 -1.2155e-
10 −7^10 −6^10 −5^10 −4^10 −3^10 −2^10 − 10 −
10 −
10 −
100 errors vs. h for function u_
Figure 2: Log-log plot of errors vs. h for test function u 2. + = D+, o = D 0 , × = D 3.
Third test function: This function shows the expected asymptotic behavior for sufficiently small values of h (until cancellation contaminates D 3 , at least), but does not show the expected rates for larger values of h. The reason is because the function u 3 (x) is not smooth at the point x = 1.001. The first derivative looks like a square root while the second and higher derivatives blow up at this point. If we difference across a point of nonsmoothness, we cannot expect the convergence rates based on Taylor series expansions to be valid. For h < 10 −^3 , however, all of the points in the difference formulas are on the same side of the singularity, the solution is now smooth and we see the expected rates.
h D+ error D_0 error D_3 error
1.0000e-01 3.5861e-01 4.2691e-02 -1.9368e- 1.0000e-02 1.2965e-01 3.2440e-02 1.2827e- 1.0000e-03 1.5811e-02 2.7128e-03 1.1890e- 1.0000e-04 1.2064e-03 1.9801e-05 1.3533e- 1.0000e-05 1.1878e-04 1.9765e-07 1.4678e- 1.0000e-06 1.1861e-05 1.9777e-09 9.9724e- 1.0000e-07 1.1858e-06 1.8403e-11 1.6190e-
10 −7^10 −6^10 −5^10 −4^10 −3^10 −2^10 − 10 −
10 −
10 −
10 −
10 −
10 −
100 errors vs. h for function u_
Figure 3: Log-log plot of errors vs. h for test function u 3. + = D+, o = D 0 , × = D 3.