Math 232: Numerical Analysis II Homework 1

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (2 votes)

1. This problem provides an alternative interpretation of finite difference approximations.
Derive approximations for u
0
(x) by (i) fitting each of the sets of data below to the highest
order polynomial you are able to consider, and then (ii) taking the exact derivative of that
polynomial and evaluating that result at x.
(a) {u(x), u(x + h)}
(b) {u(x − h), u(x)}
(c) {u(x − h), u(x), u(x + h)}
Show that your results correspond exactly to D+u(x), D−u(x) and D0u(x), respectively.
Discuss how this alternative derivation of these finite difference formulas informs your understanding of their respective truncation errors.
2. This problem provides an introduction to the fdstencil.m code that we will use for other
problems in this class.
(a) Use the method of undetermined coefficients to set up the 5 × 5 Vandermonde system
that would determine a fourth-order accurate finite difference approximation to u
00(x)
based on 5 equally spaced points,
u
00(x) = c−2u(x − 2h) + c−1u(x − h) + c0u(x) + c1u(x + h) + c2u(x + 2h) + O(h
4
).
(b) Compute the coefficients using the Matlab code fdstencil.m available from the CatCourses website, and check that they satisfy the system you determined in part (a).
1
Math 232: Numerical Analysis II Homework 1
(c) Test this finite difference formula to approximate u
00(1) for u(x) = sin(2x) with values of
h from the array hvals = logspace(-1, -4, 13). Make a table of the error vs. h for
several values of h and compare against the predicted error from the leading term of the
expression printed by fdstencil. You may want to look at the m-file chap1example1.m
for guidance on how to make such a table.
Also produce a log-log plot of the absolute value of the error vs. h. Be sure to label axes,
include a legend, and any other items needed to make this plot clear and understandable.
You should observe the predicted accuracy for larger values of h. For smaller values,
numerical cancellation in computing the linear combination of u values impacts the
accuracy observed.
2