Sample Homework with Solution - Time-Dependent Probe | AMATH 586, Assignments of Mathematics

Material Type: Assignment; Professor: Leveque; Class: TIME DEPNDT PROBS; Subject: Applied Mathematics; University: University of Washington - Seattle; Term: Spring 2007;

Typology: Assignments

Pre 2010

Uploaded on 03/18/2009

koofers-user-t72
koofers-user-t72 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
AMath 586
Sample Homework
Spring, 2007
Format for homework solutions and a sample write-up
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
1. Hands on experience in using various algorithms by writing your own programs and/or using software.
This should increase your understanding of the advantages, limitations, and proper use of various
algorithms.
2. Practice in designing numerical experiments and interpreting the results, both as a computational
scientist using a method to study some physical problem and as a numerical analyst attempting to
understand the behavior of an algorithm.
3. Practice in writing up your results and analysis in a manner that it can be understood and appreciated
by others.
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.
1. A brief description of the problem.
2. A description of the method you have used to solve it, with documentation of what choices you have
made for any parameters, stepsizes, error tolerances, etc.
3. Results obtained, presented in a suitable format. If the solution is a function then a graph is typically
easier to interpret than a long list of numbers. If the exact solution is available then a comparison
of the two on the same graph is useful. Comparision of results with different parameter choices (e.g.,
with different step sizes to show convergence) can often be done on a single graph with goo d labeling
so that it can be clearly read. If the error is so small that it is hard to distinguish one graph from
another, a separate graph of the errors (suitably scaled) may be best.
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.
4. Analysis of results, e.g., computation of convergence rates from the computed results. Also compare
your results with the theory, explain any strange behavior observed, make comparisons of different
methods if relevant, etc.
1
pf3
pf4
pf5

Partial preview of the text

Download Sample Homework with Solution - Time-Dependent Probe | AMATH 586 and more Assignments Mathematics in PDF only on Docsity!

AMath 586 Sample Homework Spring, 2007

Format for homework solutions and a sample write-up

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

  1. Hands on experience in using various algorithms by writing your own programs and/or using software. This should increase your understanding of the advantages, limitations, and proper use of various algorithms.
  2. Practice in designing numerical experiments and interpreting the results, both as a computational scientist using a method to study some physical problem and as a numerical analyst attempting to understand the behavior of an algorithm.
  3. Practice in writing up your results and analysis in a manner that it can be understood and appreciated by others.

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.

  1. A brief description of the problem.
  2. A description of the method you have used to solve it, with documentation of what choices you have made for any parameters, stepsizes, error tolerances, etc.
  3. Results obtained, presented in a suitable format. If the solution is a function then a graph is typically easier to interpret than a long list of numbers. If the exact solution is available then a comparison of the two on the same graph is useful. Comparision of results with different parameter choices (e.g., with different step sizes to show convergence) can often be done on a single graph with good labeling so that it can be clearly read. If the error is so small that it is hard to distinguish one graph from another, a separate graph of the errors (suitably scaled) may be best.

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.

  1. Analysis of results, e.g., computation of convergence rates from the computed results. Also compare your results with the theory, explain any strange behavior observed, make comparisons of different methods if relevant, etc.
  1. Computer code. Please attach your code, or at least a sample of it. If you have several different versions with minor modifications, then one representative version would be enough. Please provide some documentation in the program so that it is possible to figure it out.

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.

Problem

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.

Solution

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.