MATH 375 Assignment 4

By Brenton LeMesurier

Drafts due Monday March 1 (There is a bonus for doing this part on time)

Final version due Monday March 8

# Get a "time stamp" for when the Python code in this notebook was last run.
from time import strftime,localtime
print(strftime("This file last run on %Y-%m-%d at %H:%M", localtime()))
This file last run on 2021-02-22 at 16:31

Exercise 0: Using this notebook as a template for yours

Start work on this and future assignments as follows:

  • Download a copy of this notebook, saving it either under the same name assignment4.ipynb or with your name or initials appended in some way, such as assignment4-Brenton-LeMesurier.ipynb or assignment4-BL.ipynb

  • Edit the top “title page” cell, inserting your name and the current date, and keep that date up-to-date. As an alternative on the date, you can use module time to get a date-and-time stamp; see above.

  • Note that I have broken up each exercise into cells for each part — insert you work in between, so that the statement of each part is kept close to your work on it.

Also, before uploading a notebook, do a “clean run” either with the “fast-forward” button above or with the menu selection

Kernel > Restart Kernel and Run all Cells ...

and then check that the output is as you expect.

import numpy as np
import matplotlib.pyplot as plt

# If you find it more convenient,
# you can import some items on a "first name basis";
# For example you can use `sin(x)` instead of `np.sin(x)` with:
from numpy import sin
# ... and `plot(...)` instead of `plt.plot(...)` and so on, with:
from matplotlib.pyplot import figure, plot, title, grid

Exercise 1. Row Reduction with Maximal Element Pivoting

A)

Repeat Exercise 3 of Assignment 3, except using maximal element partial pivoting. That is, solve the system of equations

\[\begin{split} \left[ \begin{array}{ccc} 4. & 2. & 1. \\ 9. & 3. & 1. \\ 25. & 5. & 1. \end{array} \right] x = \left[ \begin{array}{c} 0.693147 \\ 1.098612 \\ 1.609438 \end{array} \right] \end{split}\]
  • using maximal element partial pivoting,

  • working by hand,

  • rounding each intermediate result to four significant digits, and

  • writing down each intermediate version of the system of equations.

B)

Then compare the residuals for these two methods (with and without pivoting), and comment.

Exercise 2: LU Factorization by the Direct Doolittle Method

A)

Construct the Doolittle LU factorization of the above matrix, again with rounding to four significant digits. Do this by the direct algorithm, not by using the values for \(U\) and such that arise from the basic row reduction algorithm.

(You may check your results with those from row reduction in Assignment 3 and/or more accurate calculation using Python.)

B)

Then solve \(Lc=b\) for \(c\) by forward substitution — again with four-significant digit rounding — and compare to the result seen with basic row reduction of Ax = b to \(Ux = c\). You only need round the result for each value \(c_1\), \(c_2\), etc., not after each individal multplication, addition and subtration: explain why!

Exercise 3: Derivatives and the Method of Undetermined Coefficients

Further details coming after we have finished this topic in class.

A)

Derive a symmetric five-point approximation of the second derivative, using the Method of Undetermined Coefficients; I recomend that you use the simpler second, “monomials” approach.

Note: try to exploit symmetry to reduce the number of equations that need to be solved.

B)

Use the symmetric centered difference approxmation of the second derivative and Richardson extrapolation to get another more accurate approximaton of this derivative.

Then compare to the result in part (A).


This work is licensed under Creative Commons Attribution-ShareAlike 4.0 International