...
...
12 Numerical Analysis
1. Numerical Methods . . . 12-1 2. Finding Roots: Bisection Method . . . 12-1 3. Finding Roots: Newton’s Method . . . 12-2 4. Nonlinear Interpolation: Lagrangian
Interpolating Polynomial . . . 12-2 5. Nonlinear Interpolation: Newton’s
Interpolating Polynomial . . . 12-3
1. NUMERICAL METHODS
Although the roots of second-degree polynomials are easily found by a variety of methods (by factoring, completing the square, or using the quadratic equation), easy methods of solving cubic and higher-order equa-tions exist only for specialized cases. However, cubic and higher-order equations occur frequently in engineering, and they are difficult to factor. Trial and error solutions, including graphing, are usually satisfactory for finding only the general region in which the root occurs.
Numerical analysis is a general subject that covers, among other things, iterative methods for evaluating roots to equations. The most efficient numerical meth-ods are too complex to present and, in any case, work by hand. However, some of the simpler methods are pre-sented here. Except in critical problems that must be solved in real time, a few extra calculator or computer iterations will make no difference.1
2. FINDING ROOTS: BISECTION METHOD The bisection method is an iterative method that “brack-ets” (also known as “straddles”) an interval containing the root or zero of a particular equation.2The size of the interval is halved after each iteration. As the method’s name suggests, the best estimate of the root after any iteration is the midpoint of the interval. The maximum error is half the interval length. The procedure continues until the size of the maximum error is“acceptable.”3 The disadvantages of the bisection method are (a) the slowness in converging to the root, (b) the need to know
the interval containing the root before starting, and (c) the inability to determine the existence of or find other real roots in the starting interval.
The bisection method starts with two values of the independent variable, x = L0and x = R0, which strad-dle a root. Since the function passes through zero at a root, fðL0Þ and f ðR0Þ will have opposite signs. The following algorithm describes the remainder of the bisection method.
Let n be the iteration number. Then, for n = 0, 1, 2, . . ., perform the following steps until sufficient accuracy is attained.
step 1: Set m¼12ðLnþ RnÞ.
step 2: Calculate fðmÞ.
step 3: If fðLnÞf ðmÞ 0, set Ln+1 = Lnand Rn+1 = m.
Otherwise, set Ln+1 = m and Rn+1= Rn. step 4: fðxÞ has at least one root in the interval [Ln+1,
Rn+1]. The estimated value of that root, x, is x12ðLnþ1þ Rnþ1Þ
The maximum error is12ðRnþ1 Lnþ1Þ.
Example 12.1
Use two iterations of the bisection method to find a root of
fðxÞ ¼ x3 2x 7 Solution
The first step is to find L0and R0, which are the values of x that straddle a root and have opposite signs. A table can be made and values of f (x) calculated for random values of x.
x 2 1 0 +1 +2 +3
f (x) 11 6 7 8 3 +14
Since fðxÞ changes sign between x = 2 and x = 3, L0= 2 and R0= 3.
First iteration, n = 0:
m¼12ðLnþ RnÞ ¼ 12
ð2 þ 3Þ ¼ 2:5
fð2:5Þ ¼ x3 2x 7 ¼ ð2:5Þ3 ð2Þð2:5Þ 7 ¼ 3:625
1Most advanced hand-held calculators have “root finder” functions that use numerical methods to iteratively solve equations.
2The equation does not have to be a pure polynomial. The bisection method requires only that the equation be defined and determinable at all points in the interval.
3The bisection method is not a closed method. Unless the root actually falls on the midpoint of one iteration’s interval, the method continues indefinitely. Eventually, the magnitude of the maximum error is small enough not to matter.
Backgroundand Support
...
...
Since fð2:5Þ is positive, a root must exist in the interval [2, 2.5]. Therefore, L1= 2 and R1= 2.5. At this point, the best estimate of the root is
x 12
ð2 þ 2:5Þ ¼ 2:25
The maximum error is 12
ð2:5 2Þ ¼ 0:25.
Second iteration, n = 1:
m¼ 12
ð2 þ 2:5Þ ¼ 2:25
fð2:25Þ ¼ ð2:25Þ3 ð2Þð2:25Þ 7 ¼ 0:1094 Since fð2:25Þ is negative, a root must exist in the inter-val [2.25, 2.5]. Therefore, L2= 2.25 and R2= 2.5. The best estimate of the root is
x12ðLnþ1þ Rnþ1Þ 12
ð2:25 þ 2:5Þ ¼ 2:375
The maximum error is 12
ð2:5 2:25Þ ¼ 0:125.
3. FINDING ROOTS: NEWTON’S METHOD Many other methods have been developed to overcome one or more of the disadvantages of the bisection method. These methods have their own disadvantages.4 Newton’s method is a particular form of fixed-point iteration. In this sense, “fixed point” is often used as a synonym for“root” or “zero.” However, fixed-point itera-tions get their name from funcitera-tions with the character-istic property x = g(x) such that the limit of g(x) is the fixed point (i.e., is the root).
All fixed-point techniques require a starting point. Pref-erably, the starting point will be close to the actual root.5 And, while Newton’s method converges quickly, it requires the function to be continuously differentiable.
Newton’s method algorithm is simple. At each iteration (n = 0, 1, 2, etc.), Eq. 12.1 estimates the root. The maximum error is determined by looking at how much the estimate changes after each iteration. If the change between the previous and current estimates (represent-ing the magnitude of error in the estimate) is too large, the current estimate is used as the independent variable for the subsequent iteration.6
xnþ1¼ gðxnÞ ¼ xnfðxnÞ
f0ðxnÞ 12:1
Example 12.2
Solve Ex. 12.1 using two iterations of Newton’s method.
Use x0= 2.
Solution
The function and its first derivative are fðxÞ ¼ x3 2x 7
f0ðxÞ ¼ 3x2 2 First iteration, n = 0:
x0¼ 2
fðx0Þ ¼ f ð2Þ ¼ ð2Þ3 ð2Þð2Þ 7 ¼ 3 f0ðx0Þ ¼ f0ð2Þ ¼ ð3Þð2Þ2 2 ¼ 10
x1¼ x0fðx0Þ
f0ðx0Þ¼ 2 3 10 ¼ 2:3 Second iteration, n = 1:
x1¼ 2:3
fðx1Þ ¼ ð2:3Þ3 ð2Þð2:3Þ 7 ¼ 0:567 f0ðx1Þ ¼ ð3Þð2:3Þ2 2 ¼ 13:87 x2¼ x1fðx1Þ
f0ðx1Þ¼ 2:3 0:567
13:87¼ 2:259
4. NONLINEAR INTERPOLATION:
LAGRANGIAN INTERPOLATING POLYNOMIAL
Interpolating between two points of known data is com-mon in engineering. Primarily due to its simplicity and speed, straight-line interpolation is used most often.
Even if more than two points on the curve are explicitly known, they are not used. Since straight-line interpola-tion ignores all but two of the points on the curve, it ignores the effects of curvature.
A more powerful technique that accounts for the curva-ture is the Lagrangian interpolating polynomial. This method uses an nth degree parabola (polynomial) as the interpolating curve.7 This method requires that fðxÞ be continuous and real-valued on the interval [x0, xn] and that n + 1 values of fðxÞ are known cor-responding to x0, x1, x2, . . ., xn.
The procedure for calculating fðxÞ at some intermediate point, x*, starts by calculating the Lagrangian interpo-lating polynomial for each known point.
LkðxÞ ¼Yn
i¼0 i6¼k
x xi
xk xi
12:2
4The regula falsi (false position) method converges faster than the bisection method but is unable to specify a small interval containing the root. The secant method is prone to round-off errors and gives no indication of the remaining distance to the root.
5Theoretically, the only penalty for choosing a starting point too far away from the root will be a slower convergence to the root.
6Actually, the theory defining the maximum error is more definite than this. For example, for a large enough value of n, the error decreases approximately linearly. Therefore, the consecutive values of xnconverge linearly to the root as well.
7The Lagrangian interpolating polynomial reduces to straight-line interpolation if only two points are used.
BackgroundandSupport
...
The value of fðxÞ at x*is calculated from Eq. 12.3.
fðxÞ ¼
å
nk¼0
fðxkÞLkðxÞ 12:3
The Lagrangian interpolating polynomial has two pri-mary disadvantages. The first is that a large number of additions and multiplications are needed.8The second is that the method does not indicate how many interpolat-ing points should be (or should have been) used. Other interpolating methods have been developed that over-come these disadvantages.9
Example 12.3
A real-valued function has the following values.
fð1Þ ¼ 3:5709 fð4Þ ¼ 3:5727 fð6Þ ¼ 3:5751
Use the Lagrangian interpolating polynomial to esti-mate the value of the function at 3.5.
Solution
The procedure for applying Eq. 12.2, the Lagrangian interpolating polynomial, is illustrated in tabular form.
Notice that the term corresponding to i = k is omitted from the product.
3.5 – 1 1 – 1
( ) (
3.5 – 41 – 4) (
3.5 – 61 – 6)
⫽ 0.08333
3.5 – 1 4 – 1
( (
) (
35 – 44 – 4(
) (
3.5 – 64 – 6)
⫽ 1.04167
3.5 – 1
6 – 1
)
3.5 – 46 – 4) (
3.5 – 66 – 6)
⫽ –0.12500
i ⫽ 0 i ⫽ 1 i ⫽ 2
L1(3.5) ⫽ L0(3.5) ⫽
L2(3.5) ⫽ k ⫽ 0:
k ⫽ 1:
k ⫽ 2:
Equation 12.3 is used to calculate the estimate.
fð3:5Þ ¼ ð3:5709Þð0:08333Þ þ ð3:5727Þð1:04167Þ þ ð3:5751Þð0:12500Þ
¼ 3:57225
5. NONLINEAR INTERPOLATION: NEWTON’S INTERPOLATING POLYNOMIAL
Newton’s form of the interpolating polynomial is more efficient than the Lagrangian method of interpolating between known points.10Given n + 1 known points for fðxÞ, the Newton form of the interpolating polynomial is
fðxÞ ¼
å
ni¼0
f½x0; x1; . . . ; xiYi1
j¼0
ðx xjÞ
!
12:4
f½x0; x1; . . . ; xi is known as the ith divided difference.
f½x0; x1; . . . ; xi ¼
å
ik¼0
fðxkÞ ðxk x0Þ ðxk xk1Þ
ðxk xkþ1Þ ðxk xiÞ 0
BB B@
1 CC CA
12:5
It is necessary to define the following two terms.
f½x0 ¼ f ðx0Þ 12:6
Yðx xjÞ ¼ 1 ½i ¼ 0 12:7
Example 12.4
Repeat Ex. 12.3 using Newton’s form of the interpolat-ing polynomial.
Solution
Since there are n + 1 = 3 data points, n = 2. Evaluate the terms for i = 0, 1, and 2.
i = 0:
f½x0Y1
j¼0ðx xjÞ ¼ f ðx0Þð1Þ ¼ f ðx0Þ i = 1:
f½x0; x1Y0
j¼0
ðx xjÞ ¼ f ½x0; x1ðx x0Þ
f½x0; x1 ¼ fðx0Þ
x0 x1þ fðx1Þ x1 x0
8As with the numerical methods for finding roots previously discussed, the number of calculations probably will not be an issue if the work is performed by a calculator or computer.
9Other common methods for performing interpolation include the Newton form and divided difference table.
10In this case, “efficiency” relates to the ease in adding new known points without having to repeat all previous calculations.
Backgroundand Support
i = 2:
f½x0; x1; x2Y1
j¼0
ðx xjÞ ¼ f ½x0; x1; x2ðx x0Þ
ðx x1Þ
f½x0; x1; x2 ¼ fðx0Þ ðx0 x1Þðx0 x2Þ
þ fðx1Þ ðx1 x0Þðx1 x2Þ þ fðx2Þ
ðx2 x0Þðx2 x1Þ
Use Eq. 12.4. Substitute known values.
fð3:5Þ ¼
å
ni¼0
f½x0; x1; . . . ; xiYi1
j¼0ðx xjÞ
¼ 3:5709 þ 3:5709
1 4 þ3:5727 4 1
ð3:5 1Þ
þ 3:5709
ð1 4Þð1 6Þþ 3:5727 ð4 1Þð4 6Þ þ 3:5751
ð6 1Þð6 4Þ
!
ð3:5 1Þð3:5 4Þ
¼ 3:57225
This answer is the same as that determined in Ex. 12.3.
BackgroundandSupport
...
...
...