Nemerical Methods Julian
Nemerical Methods Julian
Nemerical Methods Julian
for
Introduction
(1)
(2) for
provided that .
If the value is chosen close enough to the root p, then the sequence generated in
(2) will converge to the root p. Sometimes the speed at which converges is
fast (quadratic) and at other times it is slow (linear). To distinguish these two cases we
make the following definitions.
(3) If , and
The mathematical characteristic for determining which case occurs is the "multiplicity"
of the root p.
(8) .
(10)
Derivation
(11) for
Method A has the disadvantage that the order m of the root must be known a
priori. Determining m is often laborious because some type of mathematical analysis
must be used. It is usually found by looking at the values of the higher derivatives
of . That is, has a root of order m at if and only if
(12) .
Dodes (1978, pp. 81-82) has observed that in practical problems it is unlikely that we
will know the multiplicity. However, a constant m should be used in (8) to speed up
convergence, and it should be chosen small enough so that does not shoot to the
wrong side of p. Rice (1983, pp. 232-233) has suggested a way to empirically
find m. If is a good approximation to p and , and somewhat distant
from then m can be determined by the calculation:
(13) for .
Our task is to determine the value m to use in formula (13), because it is not known a
priori. First, we take the derivative of in formula (5), and obtain:
(14)
.
This enables us to rewrite (13) as
(15) .
(16) , where .
(17) for
(18) .
(19) .
(20) .
Figure 1. The values for the "linear search" obtained by using
formula (15)
near a "double root" p (of order ). Notice
that .
(21) .
Example 1. Use the value and compare Methods A,B and C for finding the
double root of the equation .
Solution 1.
When the function has a triple root, then one more iteration for the linear search in
(13) is necessary. The situation is shown in Figure 2.
Figure 2. The values for the "linear search" obtained by using
formula (15)
near a "triple root" p (of order ). Notice that
.
Example 2. Use the value and compare Methods A,B and C for finding the
triple root of the equation .
Example 3. Use the value and compare Methods A,B and C for finding the
quadruple root of the equation
Acknowledgement
This module uses Mathematica instead of Pascal, and the content is that of the article:
John Mathews, An Improved Newton's Method, The AMATYC Review, Vol. 10, No. 2,
Spring, 1989, pp. 9-14.
References
1. Dodes, 1. A., Numerical analysis for computer science, 1978, New York: North-
Holland.
2. Mathews, J. H., Numerical methods for computer science, engineering and
mathematics, 1987, Englewood Cliffs, NJ: Prentice-Hall.
3. Ralston, A. & Rabinowitz, P., A first course in numerical analysis, second ed., 1978,
New York: McGraw-Hill.
4. Rice, J. R., Numerical methods, software and analysis: IMSL reference edition,
1983, New York: McGraw-Hill.
Module
for
Background. The bisection method is one of the bracketing methods for finding roots
of equations.
Implementation. Given a function f(x) and an interval which might contain a root,
perform a predetermined number of iterations using the bisection method.
Limitations. Investigate the result of applying the bisection method over an interval
where there is a discontinuity. Apply the bisection method for a function using an
interval where there are distinct roots. Apply the bisection method over a "large"
interval.
Theorem (Bisection Theorem). Assume that and that there exists a number
such that .
If have opposite signs, and represents the sequence of midpoints
generated by the bisection process, then
for ,
That is, .
After you have debugged you program and it is working properly, delete the
unnecessary print statements.
Now test the example to see if it still works. Use the last case in Example 1 given above
and compare with the previous results.
Example 3. Convergence Find the solution to the cubic equation
. Use the starting interval .
Solution 3.
Example 4. Not a root located Find the solution to the equation . Use the
starting interval .
Solution 4.
Old Lab Project (Bisection Method Bisection Method). Internet hyperlinks to an old
lab project.
Module
for
The formula for the secant method is the same one that was used in the regula falsi
method, except that the logical decisions regarding how to define each succeeding term
are different.
Theorem (Secant Method). Assume that and there exists a number
, where . If , then there exists a such that the
sequence defined by the iteration
for
for .
The following subroutine call uses a maximum of 20 iterations, just to make sure
enough iterations are performed.
However, it will terminate when the difference between consecutive iterations is less
than .
By interrogating k afterward we can see how many iterations were actually performed.
Example 3. Fast Convergence Find the solution to .
Use the Secant Method and the starting approximations and .
Solution 3.
Secant Method Secant Method Internet hyperlinks to web sites and a bibliography of
articles.
Module
for
Background. The Regula Falsi method is one of the bracketing methods for finding
roots of equations.
Implementation. Given a function f(x) and an interval which might contain a root,
perform a predetermined number of iterations using the Regula Falsi method.
Limitations. Investigate the result of applying the Regula Falsi method over an interval
where there is a discontinuity. Apply the Regula Falsi method for a function using an
interval where there are distinct roots. Apply the Regula Falsi method over a "large"
interval.
Theorem (Regula Falsi Theorem). Assume that and that there exists a
number such that .
If have opposite signs, and
represents the sequence of points generated by the Regula Falsi process, then the
sequence converges to the zero .
That is, .
Proof False Position or Regula Falsi Method False Position or Regula Falsi
Method
Remember. The Regula Falsi method can only be used to find a real root in an
interval [a,b] in which f[x] changes sign.
Example 2. Use the cubic equation in Example 1 and perform the
following call to the Regula Falsi subroutine.
Solution 2.
After you have debugged you program and it is working properly, delete the
unnecessary print statements.
Now test the example to see if it still works. Use the last case in Example 1 given above
and compare with the previous results.
The following program uses fewer computations in the Regula Falsi method and is the
traditional way to do it. Can you determine how many fewer functional evaluations are
used ?
Regula Falsi Method Regula Falsi Method Internet hyperlinks to web sites and a
bibliography of articles.
Download this Mathematica Notebook Regula Falsi Method
Module
for
Gauss-Jordan Elimination
(i) Given any matrix , the linear system has a unique solution.
It is convenient to store all the coefficients of the linear system in one array of
dimension . The coefficients of are stored in column of the array (i.e.
). Row contains all the coefficients necessary to represent the equation
in the linear system. The augmented matrix is denoted and the linear system
is represented as follows:
The system , with augmented matrix , can be solved by performing row
operations on . The variables are placeholders for the coefficients and cam be
omitted until the end of the computation.
(iii) Replacement: Row r can be replaced by the sum of that tow and a nonzero
multiple of any other row;
that is: .
It is common practice to implement (iii) by replacing a row with the difference of that
row and a multiple of another row.
Definition (Pivot Element). The number in the coefficient matrix that is used to
eliminate where , is called the pivot element, and the
row is called the pivot row.
system .
Solution 1.
Example 2. Interchange rows 2 and 3 and try to use the Gauss-Jordan subroutine to
solve .
Use lists in the subscript to select rows 2 and 3 and perform the row interchange.
Solution 2.
interchanges to solve .
Use the matrix A and vector B in Example 2.
Solution 3.
system .
Solution 4.
Use the subroutine "GaussJordan" to find the inverse of a matrix.
matrix .
Solution 5.
Remark. The Gauss-Jordan elimination method is the "heuristic" scheme found in most
linear algebra textbooks. The line of code
divides each entry in the pivot row by its leading coefficient . Is this step
necessary? A more computationally efficient algorithm will be studied which uses
upper-triangularization followed by back substitution. The partial pivoting strategy will
also be employed, which reduces propagated error and instability.
Consider a polynomial of degree n=5 that passes through the six points
;
.
For each point is used to an equation , which in turn are used to
write a system of six equations in six unknowns
=
=
=
=
=
=
Solve this linear system for the coefficients and then construct the
interpolating polynomial
Example 6. Find the polynomial p[x] that passes through the six
points using the following steps.
(a). Write down the linear system MC = B to be solved.
(b). Solve the linear system for the coefficients using our Gauss-Jordan subroutine.
(c). Construct the polynomial p[x].
Solution 6.
Module
Iterative schemes require time to achieve sufficient accuracy and are reserved for
large systems of equations where there are a majority of zero elements in the matrix.
Often times the algorithms are taylor-made to take advantage of the special structure
such as band matrices. Practical uses include applications in circuit analysis, boundary
value problems and partial differential equations.
Consider that the n×n square matrix A is split into three parts, the main diagonal D,
below diagonal L and above diagonal U. We have A = D - L - U.
-
Definition (Diagonally Dominant). The matrix is strictly diagonally dominant if
for .
where
and .
where
and .
system .
Try 10, 20 and 30 iterations.
system .
Try 10 iterations.
Observe that something is not working. In example 5 we will check to see if this matrix
is diagonally dominant.
system .
Try 10, 20 iterations. Compare the speed of convergence with Jacobi iteration.
system .
Try 10 iterations.
Observe that something is not working. In example 5 we will check to see if this matrix
is diagonally dominant.
.
Mathematica Subroutine (Gauss-Seidel Iteration).
system .
Use a tolerance of and a maximum of 50 iterations.
for
Background.
Theorem (Three point rule for ). The central difference formula for the first
derivative, based on three points is
where . This gives rise to the Big "O" notation for the error
term for :
Theorem (Three point rule for ). The central difference formula for the
second derivative, based on three points is
,
where . This gives rise to the Big "O" notation for the error
term for :
Project I.
Example 1. Consider the function . Find the formula for the third
derivative , it will be used in our explorations for the remainder term and the
truncation error bound. Graph . Find the bound
. Look at it's graph and estimate the value , be sure to take the absolute value if
necessary.
Project II.
Aside. It looks like the formula is a second divided difference, i.e. the difference
quotient of two difference quotients. Such is the case.
Aside. From a mathematical standpoint, we expect that the limit of the second divided
difference is the second derivative. Such is the case.
Example 5. Consider the function . Find the formula for the fourth
derivative , it will be used in our explorations for the remainder term and the
truncation error bound. Graph . Find the bound
. Look at it's graph and estimate the value , be sure to take the absolute value if
necessary.
for
Furthermore, if , then there exists a value c with a < c < b so that the
error term has the form
Remark. When the step size is reduced by a factor of the error term
Example 4. Use the "true value" in example 3 and find the error for the trapezoidal rule
approximations in example 2.
Example 5. When the step size is reduced by a factor of the error term
Example 9. Use the "true value" in example 8 and find the error for the trapezoidal rule
approximations in exercise 7.
Example 10. When the step size is reduced by a factor of the error term
for .
where .
The recursive trapezoidal rule is used for the Romberg integration algorithm.
Module
for
Example 3. Find the analytic value of the integral (i.e. find the
"true value").
Example 4. Use the "true value" in example 3 and find the error for the Simpson rule
approximations in example 2.
Example 5. When the step size is reduced by a factor of the error term
Example 9. Use the "true value" in example 8 and find the error for the Simpson rule
approximations in example 7.
Example 10. When the step size is reduced by a factor of the error term
Module
for
where and the mesh size of the partition goes to zero in the "limit," i.e
. .
The following two Mathematica subroutines are used to illustrate this concept, which
was introduced in calculus.
Example 1. Let over . Use the left Riemann sum with n = 25, 50,
and 100 to approximate the value of the integral.
Example 2. Let over . Use the right Riemann sum with n = 25,
50, and 100 to approximate the value of the integral.
Example 3. Let over . Use the midpoint rule with n = 25, 50, and
100 to approximate the value of the integral.
Example 4. Let over . Use the trapezoidal rule with n = 25, 50,
and 100 to approximate the value of the integral.
.
Example 5. Let over . Compare the left Riemann sum, right
Riemann sum, midpoint rule and trapezoidal rule for n = 100 subintervals. Compare
them with the analytic solution.
The following animations for the upper Riemann sums are included for illustration
purposes.
Module
for
Background
In applications, it is often the case that systems of equations arise where the
coefficient matrix has a special structure. Sparse matrices which contain a majority of
zeros occur are often encountered. It is usually more efficient to solve these systems
using a taylor-made algorithm which takes advantage of the special structure. Important
examples are band matrices, and the most common cases are the tridiagonal matrices.
Definition (Tridiagonal Matrix). An n×n matrix A is called a tridiagonal matrix
if whenever . A tridiagonal matrix has the for
(1) .
The enumeration scheme for the elements in (1) do not take advantage of the
overwhelming number of zeros. If the two subscripts were retained the computer would
reserve storage for elements. Since practical applications involve large values
of , it is important to devise a more efficient way to label only those elements
that will be used and conceptualize the existence of all those off diagonal zeros. The
idea that is often used is to call elements of the main diagonal , subdiagonal
elements are directly below the main diagonal, and the superdiagonal
elements are directly above the main diagonal. Taking advantage of the single
subscripts on we can reduce the storage requirement to merely
elements. This bizarre way of looking at a tridiagonal matrix is
Observe that A does not have the usual alphabetical connection with its new elements
named , and that the length of the subdiagonal and superdiagonal is n-1.
Definition (tri-diagonal system). If A is tridiagonal, then a tridiagonal system is
(2)
(3)
=
=
=
=
=
Goals
Observation. The 31×31 matrix A in Example 1 has 961 elements, 870 of which are
zeros. This is an example of a "sparse" matrix. Do those zeros contribute to the
solution ? Since the matrix is tri-diagonal and diagonally dominant, there are other
algorithms which can be used to compute the solution. Our tri-diagonal subroutine will
work, and it requires only 12.3% as much space to save the necessary information to
solve the problem. In larger matrices the savings will be even more. It is more efficient
to use vectors instead of matrices when you have sparse matrices that are tri-diagonal.