Chapter 4 - NUMERICAL DIFFERENTIATION AND INTEGRATION
Remark: In many real-life mathematical models,
one must utilize the integral or the derivative of a given function. Sometimes,
these functions are easily differentiable or integrable. Many times they are
not or doing so would be difficult. The question becomes determining how
we can find good approximations to derivatives evaluated at given points
and to definite integrals.
One idea: For any given function (or set of data
points), determine a set of n+1 data points (x,y) and use the concepts from
Chapter 3 to find a polynomial approximation to the original function. Usually,
this polynomial approximation is very easy to differentiate and integrate.
(Actually, this is not quite as true when using the Newton-type forms of
the polynomial.) Use the resulting values from the polynomial as approximate
values for the exact values.
Computing Assignment: Determine the Lagrange
interpolating polynomial to f(x)=1/(1+x2) on the interval [-3,3]
of degree n for various n. (Use the matrix approach by setting up the Vandermonde
matrix, etc) Then, differentiate and integrate this polynomial exactly using
formulas and compare with the exact values. Experiment with at least two
other nontrivial functions for f(x) for which you can get an exact answer
via calculus.
Remark: In the following, we will only consider
determining derivatives at given points and definite integrals since each
ot these is an actual number. If an interval approximation to the derivative
function is desired or the indefinite integral is needed, the ideas which
follow will need to be implemented over and over, once for each new value
desired.
Homework: page 146, #5, 6
Numerical Integration Methods:
From the definition of integration (Limits of Reimann sums), one perhaps would think that an approximation to the value of the definite integral could be found by replacing the infinite sum with a finite one. In general, numerical quadrature is approximating the definite integral with the finite sum:Methods: To find an approximate value for the definite integral from a to b, first break up the interval into several smaller intervals (most often of uniform width h). Then, add up approximate values of the integral on each. The order of the method is the degree of the highest polynomial for which the method will obtain the exact integral.S ak f(xk),where the xk are a reasonably fine finite partition of the interval [a,b].
Computing Assignments: Implement as separate functions the forward difference, backward difference and central difference methods for determining the derivative as well as the trapezoidal rule, Simpson's rule and the midpoint rule for determining the definite integral. Approximate the deriviative and integral of f(x) = 1/(1+x2) for several different values. Compare your answers with the known exact derivative f'(x) = -2x/(1+x 2)2 and the (indefinite) integral tan-1(x). Consider other functions also and compare your approximation with the exact value via calculus.
Chapter 5 - SOLVING INITIAL VALUE PROBLEMS
Ex: Solving y'=4y gives y(t)=Ce4t
, where C is any constant. To eliminate the arbitrary constant C, we would
need an initial condition for y(a) given. For example, y(0)=3 implies y(t)=3e
4t.
General Problem: Solve for y(t) on the interval a < t < b,
(IVP) y'=f(t,y(t))
y(a) = y0
, given.
Remark: Elementary Ordinary Differential
Equation (ODE) theory gives mathematical discussions on the existence and
uniqueness of exact solutions to (IVP). (See Well-Posed Condition on page
151.) We will always assume that we are given problems for which solutions
exist and are unique.
Remark: If (IVP) cannot be solved by analytical
methods, we will need to find a discrete solution by finding an approximation
to the solution at a finite number of points. Once we have these points, we
can use approximation theory from Chapter 3 to find an approximate continuous
solution.
Notation: Given interval endpoints a and b; number of data points desired n+1; and the function f(t,y) from the D.E....
Let h=(b-a)/n, be the mesh size with equally spaced
mesh points given by tj=a+j h; wj= algorithm
generated approximation for y(tj); and set fj=f(t
j,wj), for j=0,1,2,...,n.
Euler's Method:
w0 = y 0,
wj+1 = fwj+h*fj , for j=0,1,2,...n.
Derivations of Euler's Method:
(1) Take y'(tj) = f(tj,y(t j)) and replace y(tj) by a forward difference formula.
(2) Use Taylor's theorem to expand y(tj+1 ) about tj and throw away nonlinear terms. Easily gives local error. Global Error, pg 154.
(3) Integrate from tj to tj+1 and approximate f(u,y(u)) under the integral by a constant evaluated at u=t j.
(4) Graphically, find the equation of the tangent line at t=tj and evaluate it at t=tj+1 to approximate y(tj+1).
But m=y'=f(tj,y(tj)) gives
y-wj = fj(t - tj). Plugging in t=tj+1
gives the method.
Assignment: Program Euler's Method in for solving the Differential Equations above. Represent the numerical solution graphically and compare it graphically with the known exact solutions. Give output corresponding to several different values for the step size h.
Remark: We would like to compare methods
for solving (IVP) to see which are "better" to use. To do this, consider
the difference equation written in the form wk+1 = wj
+ h*f(tk,wk), where f is "all the rest" of the method.
Define the local truncation error of a method to be t(h) = (y(t
k+1) - y(tk))/h + f(tk,yk). The
order of the method is the lowest power of h remaining in t(h) after
expanding all terms about t=tk and simplifying.
Result: Euler's method is order 1.
Taylor's Methods: page 156
To develop methods of order higher than one, use
the Taylor's exansion for y(tk+h) about tk and note
that the derivatives of y can be obtained to arbitrarly high degree by using
the D.E. y'=f(t,y), y''=f'(t,y), y'''=f''(t,y), etc, where f(t,y(t)) is a
given function.
Homework: page 159, #3, 4, 7.
Runge Kutta Methods:
Instead of evaluating f(t,y) only at "nodal" points, allow this function to be evaluated at points between nodes. The extra degrees of freedom give higher order methods which don't involve the derivative calculations needed in Taylor's methods.
(a) Midpoint Method - page 163
(b) Modified Euler Method - page 163
(c) Heun's Method - page 163
(d) Classical Runge-Kutta Method - page 164 (This
is the method most often used in practice.)
Homework: page 166, #4, 11 (Feel free to
use Software.)
Multi-Step Methods: page 168
Instead of only using information at time t to get the approximation at time t+h, use the computational values from previous time steps also. This enables one to get methods of high accuracy without the complexity of using the Runge-Kutta methods. The tradeoff is that this type of method needs more that one starting value and these must be generated by a single-step method.
-Adam's-Bashforth Methods - page 169, explicitly gives wk+1.
-Adam's-Moulton Methods - page 170, implicitly gives wk+1.
Often, these multi-step methods are used together
with an Adam's-Bashforth method used to give a first approximation to w
k+1 and then an Adam's-Moulton method used to improve this value.
Computing Assignment:
Implement both the Midpoint and Classical Runge-Kutta
methods.
Optional Programming Assignment:
Implement the Adam's Fourth-Order Predictor-Corrector Algorithm on page 266.
Chapter 6 - SOLVING SYSTEMS OF LINEAR EQUATIONS
Discuss:
(a) Determination of A-1 using the factorization. Notice, if zk is the kth column of A-1 and ek is the column vector with all zeros except for a one in the kth position, we can write the matrix equation A*A-1 = I as n matrix equations A*zk = ek. Factoring the matrix A into A=LU once, yields LUzk=ek, and notice each of these can be solved in O(n2) time.
(b) Consider a tensor product interpolating surface
x(u,v) = S S ci,j Ai(u) Bj(v), where A
i(u) and Bj(v) are basis functions. Suppose we are given
data points to interpolate xi,j. Plugging these points into the
above tensor product yields a system of equations X=ACB, where X, A, C, B
are matrices. The formal solution of this is C=A-1XB-1
, which requires O(n6) operations. Using a factorization process
carefully yields only O(n4) operations - a significant savings
for even small systems.
PROGRAMMING ASSIGNMENTS FOR MAT/CSC 381
NAME _____________________________-
Check for correctness, legibility, test cases,
presentation in MathCad, look for programming extra's or extra effort.
_____ Bernstein
_____ Bisection
_____ Newtons
_____ Secant
_____ Newton's Divided Differences
_____ MathCad Splines
_____ Lagrange Polynomial Derivatives and Integrals
_____ Difference Formulas
_____ Quadrature Formulas
_____ Euler's Method
_____ 2nd Order Taylor's Method
_____ Midpoint Runge Kutta
_____ Classical Runge Kutta