Professional Documents
Culture Documents
Nurul A. Chowdhury - Numerical Methods
Nurul A. Chowdhury - Numerical Methods
ury
Sas�atoon, Canada
•
University of Sasbtdlewan
Saskatoon, Ca2,<1da
Kendall Hunt
pub l ish i ng company
All interior images were created by the nutbor.
Kendall Hunt
pub l ish i no company
www.kendallhunt.com
Send a// inquiries to:
4050 Westmark Drive
Dubuque, IAS2004- 1840
ISBN 978-1-5249-9597-3
_J
There must be an ideal world, a sort of mathematician's paradise where
everything happens as it does in textbooks.
-Bertrand Russell
Preface .............................................................................................................................................. xi
0
0 Contents
0
~ Preface
be: helpful. Interpolation is another area that has deep collJlection to many numerical teclmiques.
Interpolation techniques have been discussed in Chapter 5. Chapters l and 5 should be part of any
course offerings at the junior Ulldergraduate level.
Chapters 1-7 can be delivered as a one term course at the junior undergraduate level. Chapters 8-1 l
can be delivered as a one term course at the senior undergraduate as well as graduate level. Instructors
may skip some of the topics without losing the continuity of their courses. A companion laboratory
class where students should be able to implement the ideas and algorithms utilizing computer pro-
grams and commercially available software of their choice will be invaluable.
I am grateful to my colleagues and students whose feedback and suggestions have been helpful in
writing this book.
Nurul A. Chowdhury
Saskatoon, Canada
PD ~ MI L R MAil I ONS-+-+---+ ---+---<-t--1
---AV- - L O S
Polynomials appear in a wide vaciety areas of mathematics, physics and basic chemistry. A
polynomial is au expression of sum of terms where each term is a product of a coefficient and var-
iables raised to exponent of non-negat ive integers. A polynomial olften represents a function. The
term with the highest sum of exponents is the leading tenn in a polynomial and the highest sum of
the exponents is the degree of a polynomial.
A polynomial in a single vaciable, x can be written as
(I.I}
(1.2)
A real polynomial is a polynomial with real coefficients, an integer polynomial is a polynomial with
integer coefficients and a complex polynomial is a polynomial with complex coefficients.
0
0 Chapter 1: Polynomial Approximations and Taylor Polynomials
Taylor polynomials can be used 10 mimic a function in the near vicinity of a given point, say, a.
Tbe degree of a Taylor polynomial increases as we impose more conditions that this polynomial
bas to satisfy.
Let us strut with a linear polynomial P, (x) that has to satisfy the conditions:
P, (a)= f(a) and
P,'(a) = f'(a)
P,'(x) = h,
Therefore,
P, (x) =h0 +h,x = J(a) - af'(a)+x f'(a) (l.5)
Example 1.1
Let /(x)=sinx anda=L
Then /(a)=0.841 and f'(a) =0.54
Therefore, the function can be approximated at a= I by the Taylor polynomial P, (x) = 0.841 +
0.54(x - J) which could be further simplified as
P, (x)=0.301+0.54x
P, (x) is approximately sinx when xis near a. •
Let us now impose an additional condition that the second derivative of the polynomial should be
equal to the second derivative of the function at a. A quadratic polynomial would be required to meet
this condition.
(1.7)
Chapter 1: Polynomial Approximations and Taylor Polynomials 0
The quadratic polynomial shown in Equation ( 1.7) must, therefore, satisfy the following three
conditions.
P1 (a) = f (a)
P;(a) = f'(a)
P{(a)=f'(a)
P; (x) = h1 + 2h2 x
P1'(x)=2h1
~(x) = h0 + h,x+h2x 1
2
P2 (x)= f(a) +(x - a) · f'(a)+½ (x - a) • f'(a) ( l.12)
0 Chapter 1: Polynomial Approximations and Taylor Polynomials
Example 1.2
Let f(x) = sinx and a= I.
Then f(a) =0.841, f'(a)=0.54 and /'(a)=-0.841
Therefore. the function can be approximated at a= I by the quadratic Taylor polynomial P2 (x) =
1
0.841+0.54(x - 1) - 0.4205(x - 1) which could be further simplified as
P2 (x)=-0.4205x1 +1.381x - 0.I 195
where P,,l'l (.r) is the ith derivative of P,, (x) and _f'-'l (x) is the ith derivative off (x). Then
(x a)a (x a)"
i:(x)=J(a)+(x - a)J<1>(a) + - f 2
l(a)+···+ - f(,,)(a)
2! n!
The polynomial P,, (x) in ( 1.13) is called the Taylor polynomial of degree n for the function f (x) at a.
Theorem:Taylor'sFormula
Suppose that / is continuously differentiable and its (n + l)th derivative exists on an interval
containing the points a and b. Then
(b - a) 2 (b - a}3 1
J(b)=f(a)+(b - a)f'(a)+ ! f'(a) + )! f >(a)
2
( 1.14)
+···+ (b - a)" ji">(a)+ (b - a)"+' i<•+')(z)
n! (11+ I)!
for some number z between a and b.
If we replace b with x in Equation ( 1.14), we get nth degree Taylor's formula with remainder at
x=a.
(t - a) 2 (x - a) l
f(x)=f(a)+(x - a)f'(a)+ · f (a)+ -'---___.c.._ f <1>(a)
1
2! 3!
(1.15)
( x - a )" An)( ) ( x - a )"+' i<•••l()
+···+ ~ ~ -; a +~ ~ - z
n! (n +l)!
Chapter 1: Polynomial Approximations and Taylor Polynomials 0
where z is some number between a and x and
(x - a t·' f "'') (z) is the nth degree remainder.
(n+I)! .
Example 1.3
Again let f (x) =sinx and a= L Then a Taylor polynomial of degree 3 to approximate f (x) at a= I
can be written using (1.13) as
3
(x - 1)2 (:c -1)
P1 (x)=0.84l+(x - 1) cos(!)- ! sin(l) · -cos(I) (1.16)
2 31
Table I. I shows values of sinx, Pi (x), P1 (x), ~ (x) and the corresponding errors of the respective
approximations. For a polynomial of fixed degree, the error increases as x moves away from a= I.
Amd, for a fixed x, the accuracy improves as the degree of the Taylor polynomial increases. ■
Example 1.4
Let f(x)=e' and a=O. Then
j!IJ(x)=e'. Jl'l(O)=lforall i~l.
Therefore.
1
P (x)=l+x+ - I x 2 +-1 x 3 +· ··+-I x • = I,
" -x (1.17)
• Jt
21. . II.I ·1
l =-01.
•
Example 1.5
Let f (x) ""e•· and a is an arbitrary point. Then
f 1l) (x) = e·', J!'l (a) =e• for all i ~ I.
0 Chapter 1: Polynomial Approximations and Taylor Polynomials
Therefore,
Example 1.6
Let / (x) = In (x) and a= L Then
f 1> ( x} = (- 1)1- 1 ( i - I)!_!,., f'l (1) =(- 1)1- 1 ( i - I)! for al I i ~ 1.
x'
Therefore, utilizing the coJTesponding Taylor polynomial is g.iven by
~ (x) = (x - 1)- .!:..(x - 1)2 +.!.(x - 1)3 - .. ·+ (- 1)"-l .!.ex - I)" •
2 3 n
1.2 Taylor'sRemainder
So far, we have seen that a Taylor polynomial P. (x) can be used to approximate a function f(x)
widun the near vicinity of a given point, x =a. However, with this approximation. we encounter a
difference between f (x) and P. (x) that is measured as
R. (x) = f (x) - P,, (x)
Example 1.7
Find a Taylor polynomial of appropriate degree to approximate sinx at a= 0 so that the error within
[-: , : ] does not exceed 10-s_
( )n+I
R.(x) x /"+1 (z)
(11 +1)!
The point z in the remainder of ( 1.1:8) is unknown, therefore, we will seek the worst possible case so
that the error does not exceed 10- 5_ In the worst case, Icos xi = 1 if n is even and Isin xi = I if II is odd.
Chapter 1: Polynomial Approximations and Taylor Polynomials 0
(x)"'' n
, ~---1 ~ 10-5 for lxl ~ - . Therefore,
(n+I)! 4
( LI 9) is satisfied when 11 ~ 7.
. . ( ) (x - a}2 .
sin.r = sma + x -a cos a - -'-----'-SIDG --'---'- COsa
(x a}3
2! 3!
4 5
(x - a) (x - a) (x - a) 6
+ -'-----''- sin a+ -'----'-cos a - -'----'-sin a
4! 5! 6!
7
( X a)
-..c-~cosa
7!
Since a=O,
. x3 x5 x1
smx=x - -+ - - - ■
31 5! 7!
In Problems 8 d1rough 14, find the Taylor polynomial and the corresponding remainder for the given
vaJ ues of a and n.
8. f(x)=cosx,a=n:/4,n=&
9. f(x)=e-•,a=l.,n=5
10. /(x)=ln(l+x). a=5 , 11=4
11. J(x)=.JI+x, a=2, 11=4
1
12. f(x)= - ,a=2,n=4
1-x
13. f(x)=si n-•x, a=n:/4,11=3
14. f(x)=tanx, a=1t/3, 11=3
Chapter 1: Polynomial Approximations and Taylor Polynomials 0
In Problems 15 through 2 1, find the Taylor series of the function at the given value of a. Show at
least the first four non-zero terms.
15. f(x)=cos.x, a=n/4
16. f(x)=e-1 ·', a= l
17. f(x)=ln(l+x). a=5
18. f(x)=lnx, a=2
1
19. f(x)= l ' a=2
(1 - x)
20. f (x) =sin-• (2:r:), a= n/4
21. f (x) =tan(x/2), a= n/3
In Problems 22 through 28, find the Maclaurin series of the given function at. Show at least the first
four non-zero tenns.
22. J(x)=cosx. a=n/4
23. f(x) = e-1x. a= I
24. f(x)=ln(l+.x),a=5
25. f(x)=lnx, a=2
I
26. f(x)= ,a =2
(1 - x) 3
27. f (x) =sin-• (2x), a= n/4
28. f (x) = tan(x/2), a= n/3
In Problems 29 through 35, find the Taylor polynomial of appropriate degree to approximate the
function at the given point a such that the maximum error does not exceed l0-5•
29. f(x)=cosx,a=n/4
30. f(x)=e-•, a=l
If f (Pt)= 0, then Pt is lhe root of the equation within [a, b ]. For sake of simplicity, we assllOle that
there is only one root within [ a, b ]. The method will, however, work if multiple roots exist in [ a, b].
<E>
0 Chapter 2: Solutions of Equations in One Variable
If f(Pt)-¢0, then f(p,) has the same sign as either f(a,) or f(b, ). When f(p,) and f(a,) have
the same sign. we conclude that the root, p is not between a, and p 1 rather p is between p1 and b,.
Therefore, we pick the subinterval (p1 , b, ] for further hal ving by setting a 2 = p, and b1 = b,.
If f(p,) and f(a 1 ) have opposite signs, we conclude that theroot,p is between a, aud p, aud we pick
Lhe subinterval [a, , p 1 ] for further h.alving by setting l2i =a1 and b2 =p,.
The halving and selecting the subinterval containing the root would continue nntil the boundaries
of the subinterval come very close to the root or the newly fonnd midpoint comes very close to the
root, p. Figure 2. l shows a few iterations of bisection algorithm.
When to stop
The iterative process would stop when the root is found, i.e.. whe,n f(Pn) =O. Sometimes how-
ever, we would be happy with a number that is indeed very close to the root. Because, it could
be a very long process before a midpoint would actually laud on the root due to the finite digit
j(x)
fib,)
.ftp,)
I
./1.P!) I
I
I
I
/11
o2 P1 h,
._I__ _,_
I _ _.,1·
In most circumstances, expression (2.1) can be used. However, in some other iterative methods
where the difference Ip., -P.-11decreases but the sequence {p,, }.__ ruverges, expression (2.1) could
become difficult to use. Although f ( p.,) "' 0 is an indication that an iterative process is approaching
the root, in many cases P. still could be far away from the actual root. This happens in asymptotic
cases and also where some slow varying function reach their maxima or minima. Expression (2.2)
indicates a relative error and can be nsed where a prior knowledge about the function and its roots
are unavailable. In an iterative process, a loop counter should be used to make sure that the number
of iterations does not exceed a maximum threshold.
The stopping criteria discussed above are also used for other root finding methods discussed in this
Chapter.
Example2.1
The equation e-• + x 3 - 5sin (x) - 13 = 0 has a root in [-6, - 2]. Table 2.1 shows the new subintervals
(new boundaries) and corresponding midpoints obtained using the 'bisection med1od. Our desired
tolerance is 0.0000 I.
II a. b
• P. Si.g n of Sign of Sign of
f (a.) f (b.) f (P.)
1 -6 -2 -4 + - -
2 -6 -4 -5 + - +
3 -5 -4 - 4.5 + - -
4 -5 -4.5 - 4.75 + - -
5 -5 -4.75 -4.875 + - -
6 -5 -4.875 - 4.9375 + - +
7 - 4.9375 -4.875 - 4.90625 + - -
8 -4.9375 -4.90625 - 4.92 188 + - +
9 -4.92188 -4.90625 - 4.91406 + - -
( Co11ri1111ed )
0 Chapter 2: Solutions of Equations in One Variable
After 20 iterations, I.here is no change in the 5'" digit place after the decimal. Therefore, the root of
the equation is -4.9 I978 with a tolerance of 0.0000 I. ■
. a +b c
S1111ce p,. = " • ,or ali 11 ~ l and
2
Chapter 2: Solutions of Equations in One Variable 0
After 11 iterations, the error bound is
b- a
<--
- 2"
Every iteration shrinks the zone containing the root into half which means with every iteration the
error bound becomes half of its value in the previous iteration.
The error bound is calculated on the basis of infinite-digit arithmetic. Consideration should be given
to the fact that computers are finite-digit machines.
Example2.2
How many iterations will be necessary to find the root wid1in an accuracy of 10- 5? For th.is part. we
are using the equation e-x + x 3 - Ssin(x) -13 = 0 that has a root in [-6, - 2].
Solutio11
b- a
IP. - Pl~r
:. - 2 - (- 6) < 10-s
2"
or, ~<10-s
2"
or, 2 2 -T" < 10-s
log10 10-5
or, (2 - n) <--'-'---
log,02
or, (2 - n)< - 16.61
or, - 2+11> 16.61
or, 11 > 18.61
or, 11 > 18.61; needs 19 iterations.
The bisection method is relatively straightforward. The principle advantage of the method is its
guaranteed convergence. Additionally, the error bound is reduced to one half with each iteration.
However, compared to the od1er metl1ods it converges more slowly.
~ Chapter 2: Solutions of Equations in One Variable
looking for x so that x = g(x). Let us say that at x = p, the condition x =g(x) is satisfied, i.e. p = g(p).
2 2
p is called a fixed-point of g. In g(x)=x2 - 30, g(6)=(6) - 30= 6 and g(- 5) =(- 5) - 30= - 5,
i.e, g(x)=x 2 - 30 has fixed points at x= - 5 and at x =6.
We can use this attribute to solve an equation f(x)=O by converting the problem to a fixed-point
problem. Rewrite /(x) = 0 into x = g(x). Thus, finding the fixed point p becomes essentially finding
the intersection of the two equation.~. y = x and y = g (x) as shown in Figure 2.3.
g(x)
0 p X
Figure 2.3 Fixed-point iteration
~ Chapter 2: Solutions of Equations in One Variable
Theorems
a. If g e c[a, b] and g (x) e [a, b] for all x e [a. b], then g has a fuced-point in [a, b].
b. If, in addition, g'(x) exists on (a, b) and a positive constant k < l exists with lg'(x)I ~ k , for
all x e (a, b ), then the fixed point in [a, b] is unique.
Am alternate way of explaining Theorem (b) follows.
Let g(x) is continuous in [a, b] and g (x) e [a, b] and a positive constant k exists such that k < 1 with
lg(x) - g(y)l ~k lx - yj for all x,ye(a,b] then the fixed point in (a. h] is unique. This means that
x =g(x) has a unique solution pin [a, b]. Also, the iterates x,, = g(x,~,) 11 '2: l will converge top for
an.y choice of x0 in [a, b].
Proof of Theorem (a)
If g(a)=a or, g(b)=b theng has a fixed point at an end point. However, if g(a);ca or, g(b);cb,
then g(a)>a and g(b)<b. The function q(x)=g(x) - x is continuous on [a,b] and satisfies the
following conditions,
q(a)=g(a) - a>O
q(b)=g(b) - b<O.
The Intermediate Value Theorem implies that there exists p e (a. b) for which q(p) =0. This means
that q(p)= g(p) - p=O. Therefore, g(p)= p i.e .. pis a fixed point for g.
Proof of Theorem (b) (i.e., the fixed point is unique)
If the fixed point is not unique, then. g (p) = p and g (r) = r, i.e., p and. rare two fixed points in [ a , b].
:.p - r=g(p) - g(r)
Now si nce p ;c r (and lg' (x)I ~ k ~ I) the Mean Value Theorem implies that a number S exists
between p and r such that
(2..4) and (2.5) are contradictions th.at come from our earlier assumption that p ;c r. Hence, p =rand
the fixed point in [a,b] is unique.
Now to prove that x,, = g (x,,_,) 11 ~ 1 will converge top for any choice of x0 in [a, b].
Chapter 2: Solutions of Equations in One Variable 0
Since g is in [a, b] for all g (x) for x e [a, b], meaning g maps [a, b] into itself, the sequence {P. }:=0
is defined for all 11 ~ 0, and p,, e [a, b] for all 11.
Let us now assume that p,, is the nth approximation for the fixed point (root), p. Then using the
M-can Value Theorem
:. IP.+, - ~ ~lc'(~)IIP. - ~
--- IP. ~~kip,. - Pl
+1 -
Replacing n+l ➔ n
Example2.3
Find the root of the equation, x 1 - 5x1 + 3x +4 = 0 within [ 0, 3] using the fixed-point iteration. Show
5 digits after decimal.
~ Chapter 2: Solutions of Equations in One Variable
Solution
The equation x 1 - 5x1 +3x+4 =0 can be rewritten in the fonn of x ,= g(x) in several ways. In this
example we will examine the following five fonns.
a. x=
J¥
- x +5x2 - 4
3
5
b. x=
3
3
x + 3x +4
c. x=
5x
d. x= ( 5x-, - 3x - 4 ) 1/l
5x 2 - 3x - 4
e. x= 2
X
Table 2.2 shows the sequences generated for (a). (b), (c), (d) and (e). A starting value of Lis selected
for all five cases. The actual root in [0, 3] is 1.61803399. It can be seen from the table that (a) and
(c) converge to the root with a tolerance of 0.00001. (c) however, took fewer iterations than (a) to
converge. (b) is oscillating between, negative and positive values. (d) and (e) will converge to a root
which is outside of the interval. In many cases. solutions wil I diverge. Convergence de_peods on the
choice of expression. We can utilize the previous discussions to select a fixed-point expression that
wiJJ converge to a solution.
•
In summary, to find a root off (x) =0 in [a, b ], a fixed-point expression should satisfy the following
conditions.
1. g(x) should be continuous and be in [a, b] for all x in [a, b].
2. g' must exist on [ a, b] and that a constant 0 < k < I exists wi th lg'(x)I ~ k, for all x in [a, bl.
3
f (x)=x - X 5X 2 + I6 x - 9
- ?
• g6 3x- - LOx+ 16
- J6x+9 - x 3 +9
g. g1 (X ) - ,- - h• g 8 (X )
X" - 5X - 5x+l6
2. 1n Prob. I .• show in each case why did the function converge (or did not converge) to the root
of f(x) =0 on [0, 1).
3. Express x 3 + I Lt 2 + I6x - 8 = 0 in the form of x = g ( x) in six different ways. Select the ones
that will have the fixed-point on the following intervals. Carry out iterations to determine the
fixed points. Use a tolerance of 10-s.
a. [- 10, - 8)
b. [-4, - 2]
c. [- 1, I]
4. Use fixed-point iterations to find solutions accurate to within I 0-5 for the following equations.
a. x 2 - 3' =0 for - 2 :;;x :;;2
b. e' + x 2 - 5 sin x = 0 for - I :;; x :;; I
c. xsinx - 3x 3 + 7 = 0 for 0.5:;; x:;; 2
5. Use fixed-point iteration to detenuine a solution accurate to within I0-1 for x 3 - 5x 2 + 8 = 0
on [0.5, 2].
6. Use fixed-point iteration to determine a solution accurate to within I 0-1 for x 3 - 5 cos (2x) - 7 = 0
on[I, 2).
7. Use fixed-point iteration to determine a solution accurate to within 10.... for 2' - 5x 2 + 12 = 0
on [- 2, 0].
8. Use fixed-point iterations to find solutions accurate to within 1o-sfor the following problems.
a. x 3 - Sx 2 +12=0, [-2,0)
b. x3 +3x + 10=0, (- 3, - 1]
c. e' - 3x - 22=0, [2, 4)
d. 5(x - 3)+sinx =0, [O, 4 )
e. 3' - e' - 17=0,[3, 5]
slope f'(p,)
The tangent line at p0 intersects with the x-axis at p, and p, becomes our next trial point. Now draw
the tangent line at p, and extend it. The slope at p 1 intersects with the .x-axis at p2 which becomes our
next trial point. Consider the trianglle with vertices {p2 , 0), {p1, 0) and (p1, f (p,)).
The slope,
f'(p,)= I (Pi)
P, - P2
(2.7)
The stopping criteria discussed for llhe bisection method also apply to Newton's method.
Example2.4
Find the root of lhe equation x 3 - 5x 1 + 3x+4 = 0 in [0, 3) using Newton 's method. Use a tolerance
of 0.00001.
~ Chapter 2: Solutions of Equations in One Variable
Solution
J(x)=x 3 - 5x 2 + 3x+4 J'(x ) = 3x 2 - 10x+3
The sequence converges to 1.61 803 with a tolerance of0.00001. So, this is the root of the equation in
[O, 3]. Keep in mind that the convergence of Newton's method depends on the initial guess. Unlike
the bisection method, Newton's method does not guarantee convergence. ■
or P - x n+J J'(0
'(p - x.)2 2j'(x.)
Assuming x •• , = x. - f (x,.) is a better approximation than x. and t;. between x. and x,..,.
J'(x.)
Let us utilise the equation x 3 - 5x1 + 3x+4 = 0 that has a root in [0, 3].
Iteration
I x, = 1.75
2 x2 = 1.6176470588
3 X3 =1.6 180339929
4 X4 = J.6180339887
5 X5 = I .6180339887
Taking 11=2
1.6 180339887 - I .6180339929
(1.6180339887 - 1.6176470588)2
p - x,,.+-J ~.0000000042
(p - x.>2 (0.0003869299) 2
~.0000000042
0.0000001497
p - x..,
(p - x.)2
~.0280561122
•
<8:> Chapter 2: Solutions of Equations in One Variable
(2. 10)
Note from Equation (2. I 5) that the Secant method requires two iuiti al approximations p0 and p 1 to
begin the iterative process. The iterative process can be shown in Figure 2.5 where p2 is the x-axis
Chapter 2: Solutions of Equations in One Variable 0
intercept of the straight line between (p0 , f (p0 )) and (p,. f (p,)), and A is the x-axis intercept of
the straight line between (p,. f (p,)) and (p2 , f (pi)).
f{x)
Like Newton's method, the Secant method is not guaranteed to converge. The condition for con-
ve·rgence for both methods are almost the same and the error formulas are also s imilar. The main
differences are: Newton's method requires two function evaluations f (x.) and f'(x.) per itera-
tion whereas the Secant method requires only one function evaluation f ( x.) per iteration provided
f {x._,) is retained from the previous iteration, and Newton's method converges more rapidly than
the Secant method. However, like Newton's method. when it converges it does so more rapidly than
the bisection method.
Example2.5
Find the root of the equation x 3 - Sx 2 + 3x+4 = 0 in [O. 3] us.ing the Secant method. Use a tolerance
of0.00001.
Solution.
f(x) =x3 - 5x 2 + 3x+4
p3=1.54545
(2. 18)
Example2.6
Find the root of d1e equation x 3 - 5sin (x)+ 24 = 0 in [-6, 6] using the method of false position. Use
a tolerance of 0.0000 l.
Solutio11
We start wid1 an initial guess of p 0 = -6 and p, = 6.
Iteration I
Calculate Pi-
Iteration 2
Calculate p3 •
Iteration 2
Calculate p..
•
Problem Set 2.3
1. Use Newton's method to find sol utions accurate to within JO..., for x3 - 5x 2 +16x - 9 =0 on
[O, l].
2. Use Newton's method to find solutions accurate to within 10_. for x 3 + llx 2 + 16x - 8 = 0 on
each interval.
a , [- 10, - 8) b. (-4,- 2) c. [- 1, 1)
Chapter 2: Solutions of Equations in One Variable <8>
3. Use the Newton 's method to find solutions accurate to within I 0-5 for the following
equations.
a. x 2 - 3' =0for - 2$x$2
b. e' +x 2 - 5sinx=0for -l $x$1
c. xsinx - 3x 3 + 7 =0 for 0.5 $x $ 2
4. Use the Secant method to find solutions accurate to within IQ--1 for x 3 - 5x 2 +16x - 9=0
on [0, 1] .
5. Use the Secant method 10 find solutions accurate to within JO-ii for x 3 + llx2 + 16.r - 8 = 0
on each interval.
a. [-1 0, - 8] b. (-4, - 2] c. [- 1, J]
6. Use the method of false position to detennine a solution accurate to within 10.... for
x 3 - 5x 1 +8 = 0 on [0.5, 2].
7. Use the method of false position to detem1ine a solution accurate to within 10.... for
x 3 - 5cos(2x) - 7=0 on [l , 2].
8. Use the method of false position to detennine a solution accurate to within 10_. for
2' - 5x 1 + 12 = 0 on [- 2, OJ.
9. Use Newton's method to find solutions accurate to within 10-5 for the following problems.
a. x 3 - 5x 2 + 12 =0, [- 2, O] b. x 3 +3x +JO= 0, [- 3, - 1]
c. e' - 3x - 22=0, (2,4] d. 5(x - 3)+sinx=0, [0, 4]
2.4 Miiller1sMethod
Miiller's method uses three initial points x0 , x, and x 2 to construct a quadratic polynomial. The poly-
nomial intersects with the x-axis at X:r This point is utilized as an improved csti!llate for the root p
of p (x) = 0. The process is then repeated with x 1, x 2 , x3 and then with x1 , x 3, x4 and so on.
Miiller's method can be used to find both real and complex roots.
Lei us construct a quadratic polynomial g(x) with the three initial points x0 , x, and x1 .
g(x) =a0 +a, (x - x 0 )+a2 (x - x0 )(x - x,) (2. I9)
Set x=x0
g(xo)=ao
Go= f (xo) (2.20)
Set x =x,
g(x,)=a0 +a, (x, - x 0 )
g(x,) - a0
a, =
x, - xo
(2.21)
Calculate x 3, the point of intersection between g(x) and the x-axis, in the following manner.
0=a0 +a, (x3 - x0 )+a2 (x1 - x0 )(,s - x,)
- {a, - {½ (x, +x0 )}± J{a, - a2 (x, +x0 )} - 41½ (a0 - a,x0 +(½x0 x,)
2
x,= - - - - - - ~ - - - - - - - - - - - - - (2.23)
. 2c'2
Example2.7
Let us utilize the previous equation x 3 - 5.r 2 + 3x + 4 = 0 that has a root in [0, 3].
Solutio11
Choose three initial points.
x0 =0, x, =land x 2 =2.
Calculate x3 and then replace x0 = x,, x, =x1 and -~ = .r3 to do the !llext iteration. Equation (2.23)
su_ggests that there will be two values of x 3• Choose the one that is within [0, 3). The results of the
subsequent iterations are shown in Table 2.4.
Chapter 2: Solutions of Equations in One Variable <B>
Table 2.4 Results of the example of Miiller's method
Xo Xi X2
•
Problem Set 2.4
1. Use MUiler's method to find solutions accurate to within IO_. for 3x3 - 5x 2 + 16x - 9=0
on [0, 1).
2. Use MUiler's method to find solutions accurate to wilhin I()-4 for x 3 + I lx 2 + l 6x - 23 = 0
on each interval.
a. [-10, - 8) b. [-4, - 2) c. [- 1, 2]
3. Use MUller·s method 10 determine a solution accurate to within 10_. for x 3 - 5x2 + 11 = 0
on [I, 2).
4. Use Muller's method to determine a solution accurate to within 10..... for x 3 - 5x 2 + l l = 0
on [- 2, 0].
5. Use MWler's method to determine a solution accurate to within JO"" for x 3 - 5cos(2x)- 7 = 0
on [I, 2).
6. Use MWler's method to de,tennine a solution accurate to within 10..., for 2' - 5x2 + 12=0
on [- 2, 0).
7. Use MW1er's method to find solutions accurate to within I0-5 for the following problems.
a. x 3 - 7x 2 +12=0, [- 2,0] b. x 3 +3x+l0=0, [-3, - 1]
c. e' - 3x - 22=0, (2,4] d. 5(x - 3)+sinx=O, [0, 4)
where the polynomial crosses tbe x-axis is calculated. This point is taken as tbe next estimate of the
root. If the estimate falls outside of the root bracket, bisection method is applied in the next iteration
in order to bracket tbe root. If the estimate falls inside the root bracke1. then inverse quadratic inter-
polation is utilized in the next iteration 10 estimate 1he root.
Take three initial points { a, f (a)}, {b, f (b )} and {c, f (c)} such that f (a)· f (b) < 0 and a< c < b.
The root is bracketed in [a, b]. The inverse quadratic polynomial ([QP) passing through the tbree
initial points is
{y- J(b)}{ y - /(c)} {y - /(a)}{y- /(b}}
x= - ~ - - ~ - - - -a+ - - - - ~ - - ~ ~c
{J(a) - f(b)}{J(a) - f(c)} {f(c) - f(a)}{J(c) - J(b)}
(2.24)
+ {y- J(a)}{ y - f (c)} b
{/(b)- f(a)}{J(b) - /(c)}
Since we are seeking for the x-axis .intercept (i.e., wbere y = 0),
x= J(b).f(c) a+ J(a)f(b) c
{J(a) - J(b)}{J(a) - /(c)} {/(c)- /(a)}{/(c)- J(b)}
(2.25)
+ f(a)J(c) b
{J(b) - f(a)}{J(b) - f(c)}
x is the next estimate of tbe root.
If x < a or x > b, use bisection method to bracket the root. If a < x < b, use the inverse quadratic
polynomial with the following update.
If J(a)· f(x) < 0, then b ➔ x . On the other hand, if f (x) · f(b) <0, then a ➔ x. c can be chosen as
tbe midpoint between a and b.
Example2.8
Take the previous equation used in ·the bisection method.
e-~ +x3 - 5sin (x) - 13=0 has a root in [- 6, - 2} Our desired tolerance is 0.00001.
Solutio11
Jtcralion I
Obtain tbe inverse quadratic polynomial that passes through the points a =-6, c =-4 and
b=- 2. Obviously, for each of these three points we have to evaluate !heir corresponding y value.
Using (2. l8)
/(-6)-/(-4)<0
Iteration 2
Obtain the inverse quadratic polynomial that passes through the points a =-6, c= - 5 and b =-4.
X - f(-4)/(- 5) . -6 + /(-6)/(-4) . -5
2
- {/ (-6)- /(-4)}{/(-6) - f (- 5)} ( ) {/ (- 5) - /(- 6)}{/(- 5) - /(-4)} ( )
/(-6)/(- 5) -4
+ {/ (-4) - /(- 6)}{/(-4)- f (- 5)} ( )
X2 =-4.84215
-4.84215 is insidef-6,-4].
f (a}· J(x2 ) < 0. Therefore, b ➔ -4.84215, i.e. the root is bracketed in [-6. -4.84215].
Iteration 3
Obtain the inverse quadratic polynomial that passes through the points a =-6. c=- 5.42108 and
b=-4.84215.
/(-4.84215)/(- 5.42108) -6
3
X = {/(-6) - f(-4.842 15)}{/(-6) - /(- 5.42!08)} ·( )
X3 =-4.90018
Jtcralion 4
Obtain the inverse quadratic polynomial that passes through the points a =-6, c = - 5.45009 and
b=-4.90018.
~ Chapter 2: Solutions of Equations in One Variable
_ / (-4.90018) / (- 5.45009) -6
x. - {J(- 6)- f (-4.90018)}{/(- 6) - / (- 5.45009)} · ( )
+ f(-6)/ (-4.90018) ·(- 5 45009)
{f(- 5.45009) - f(-6)}{/(- 5.45009) - /(-4.90018)} .
+ f(- 6)/(- 5.45009) ·(-4.90018)
{f(-4.90018) - /(- 6)}{/(-4.90018) - /(- 5.45009)}
x. =-4.91475
•
Problem Set 2.5
1. Use Brent's med1od to find solutions accurate to widiin 10..... for x 3 - J4x 1 +11 x + 2 1=0
on [- 2, 0l
2. Use Brent's med10d to find solutions accurate to widiin 10-" for x 3 - l4x 2 + I lx + 2 1=0 on
[l, 3].
3. Use Brent's method to find solutions accurate to widiin IO-" for x 3 +11x 2 + I6x - 8 = 0
on each interval.
a. [- 10, - 8] b. [-4, - 2] c. [- 1, I]
Chapter 2: Solutions of Equations in One Variable 0
4. Use B rent's method to determine a solution accurate to within 10-1 for x 3 - 5x 1 + 8 = 0 on
[0.5,2).
5. Use Brent's method to detemune a solution accurate to within 10.... for x 3 - 5cos(2x) - 7 = 0
on [I, 2].
6. Use Brent's med1od to determine a solution accurate to within I0 .... for 2' - 5x2 +12 = 0 on
[- 2, O].
7. Use Brent's method to find solutions accurate to within 10-s for d1e following problems.
a. x3 - 5x2 + 12aa0, (- 2, 0) b. x3 + 3x +!0aa0, [- 3, - I]
t
f(x)= <p(x)I1(x - A1 )"'
l=l
*
where <p(x) 0 is continuous in each neighbourhood of A1, i = 1, 2, .... k.
f (x) and its first derivative f' (x) have only one greatest common factor
k
fc(x)= Il(x - A,)"'' _,
The equation bas three distiuct roots, a simple root a and multiple roots p and q with respective
multiplicity of / and m. If a polynomial equation is presented in d1is fashion or can be converted
to this factorized form. then the roots and their multiplicity can be detennined with little difficulty.
However, most often a polynomial equation will be presented in the following manner.
•
I,ax =0 1
1
1:-0
where a1 is the ith coefficient.
We can divide the solution as a two-step process. In d1e first step, the: distinct roots are found and in
Lhe second step their multiplicities are determined.
Step 1
In order to find die distinct roots. we have to collect me distinct factors of the polynomial expression
ignoring d1eir multiplicity.
1
Let/ (x) = (x - a) (x - p) (x - q)'"
The first derivative off (x) is
g(x) = f'(x)=(x - p)' (x - qf' +l(x- a)(x - pf' (x - q)'" +111 (x - a)(x - p)' (x - q)"'-'
Note mat g (x) does not contain me common factor for simple root, however, it contains the common
factors off (x) for multiple roots whose indices have been reduced by one due to differentiation.
This makes it possible to isolate the greatest common divisor of /(x) and g(x) utilizing a suitable
technique. We use Euclidean Remainder to find dle greatest common divisor (GCD).
Euclidean remainder
Definition: Polynomial Division. Let p(x) and d (x) be polynomials with d (x) ;t, 0. Then there exist
unique polynomials, me quotient q ( x) and ilie remainder r (x) such that
p(x)"' d(x)q(x)+ r (x)
wim either r(x) = 0 or the degree of r(x) is less than that of d (x).
TJ,eorem: Euclidean Theorem for Polynomials. Let f (x) and g(x) be nonzero polynomials and r(x)
be the re111ai11derob1ai11ed by dividi11g f (x)by g(x). If GCD (J (x), g (x)) de1101es 1he GCD off (x)
and g(x), then GCD (J (x), g (x)) =GCD (g (x), r (x))
Proof
Let/, (x) be the GCD off (x) and g(x) such mat
f(x)= f, (x)q1 ( ,~) and g(x)= le (x)q, (x)
where q1 (x) and q, (x) are nonzero and have no common divisors. Dividing f (x) by g(x),
f.. (x)q1 (x) = f. (x) q, (x)q(x)+ r(x).
Chapter 2: Solutions of Equations in One Variable 0
Rearranging the above,
q1 (x) - q, (x)q(x) and q, (x) have no common divisor since there is no common divisor of q1 (x)
and q, (x). Therefore,/, (x) is the GCD of g (x) and r(x).
The Euclidean algorithm for polynomials use successive polynomial division starting by dividing
f (x) by g(x). The divisor and the remainder of any division are arranged respectively as the divi-
dend and the divisor in the subsequent division yielding a sequence of remainders, called Euclidean
remainder sequence. The repetitive divisions are continued until the remainder is zero. Ultimately,
Lhe last nonzero remainder in the sequence is the GCD of/ (x) and g(x).
a=96 40=b
2b=80 32 =2a - 4b
lj = a - 2b = 16 8=- 2a+5b =r2
-4a+l0b= 16
r3 = 5a -1 2b=0
The last nonzero remainder is 8 which is the GCD of 96 and 40. 8 can be expressed as 8 =- 2a + 5b,
and, therefore, 11 = - 2 and v = 5.
l
- {a(x) - (x+3)b(x)}=x 3 - 3x+2
4
~ Chapter 2: Solutions of Equations in One Variable
Note that in determining the polynomial extended Euclidean remainders, we convert the polynomi-
als into manic at each stage if necessary. The last nonzero remainder is
x 3 - 3x+2
and
V(x
·)I _(x - p)(x - q)+l(x - a)(.x - q)+m(x - a)(x - p)
= 111, multiplicity of root q.
· •=q (x - p)(x - q)+(x - a)(x - q)+(x - a)(x - p) , =q
Example2.9
Fillld the roots and the multiplicity of the roots of the following polynomial equation.
x 1 +5x6 +3x5 - l7x4 - 16x3 + 24x 2 + 16x - 16=0
Chapter 2: Solutions of Equations in One Variable ~
Solution
Let /(x)=x 7 +5x6 +3x 5 - 17x4 - 16x3 + 24x 2 + 16x - l6
Obtain the first derivative of /(x).
g(x) = f'(x) =1x6 +30x 5 + 15x' - 68x 3 - 48x 2 + 48x+ 16
r(x) = g(x)=7x+2
h(x)
v(x )I 2
= ?x + 1 = 3 i.e., the root at J has a multiplicity of 3, and
,=, 2x + I .,=,
v(x)I =7x + 21 =4 i.e., the root at - 2 has a multiplicity of 4.
= -i 2x + I , =-l
2.7 Convergence
Convergence analysis is performed to find if a solution process will be stable and lead to an answer.
In addition, the analysis can be utilised to ascertain the rate at which a solution process would
converge to an answer.
Rate of Convergence
Rate of convergence indicates the speed at which a so lution process would converge to an answer.
Several sol ution processes or techni ques can be compared with respect to their rate of convergence
to ascertain computational efficiency.
LiJ1ear Co11verge11.ce
A sequence {x,} is said to converge linearly to x· if there is a constant 0<c<J such that
xt+i - x • ~ ext - .i/ for all k > N for some natural number N > 0.
~ Chapter 2: Solutions of Equations in One Variable
p - p,,. , "'A-<I
p - p.
wlnere A is a constant and 11 ~ 0,
then Aitken 's extrapolation technique commonly known as Aidcen's I:!. 2 method can be used to mod-
ify the sequence so that it converges at a faster rate.
Assume that in an iterative process the approximation improves as II increases. We can write
p - p,,.,
(2.26)
l - p - JJ..2
P,,+2 - Pn+I p - p,,.._,
P,,+, - p,, p - p,,
p - p •• ,
P,,+i - Pn+I ._ ~- A
P,1+1 - p,, -- 1
l
P,,+i - Pn+I "'A
P,1+1 - 1',,
Example 2.10
Consider the equation x 3 - 7./ +4e';nc,J +8=0 that has a root in [l, 3]. We can utilize a fixed-point
iteration by using x = g (x)
x 3 + 4e"•(•) + 8
where g (x) = .1- - - - -.
7
Table 2.6 shows the results using the fixed-point iteration and Aitken 's extrapolation. For a tolerance
w-
of 1 , fixed-pointrcquires 14 iteration whereas Aitkcn's extrapolation requires 5 iteration.
<B:> Chapter 2 : Solutions of Equations in One Variable
n P. 'I.
0 1.0 l.9 119457
I 1.6 159521 l.8946464
2 1.8 158739 l.8943805
3 1.8723815 l.8944179
4 1.8882 160 1.8944223
5 1.8926724 J.8944227
6 1.8939289
7 1.8942834
8 1.8943834
9 1.8944116
10 1.8944196
11 1.8944218
12 1.8944225
13 1.8944226
14 l.8944227
•
2.8.2 Steffensen's acceleration
Steffensen's acceleration is a slight modification of Aitken's t!,.2 method as applied to fixed-point
iterations. In Aitken 's t!,.2 method as applied to a fixed-poi nt iteration the sequence proceeds as
Po, P1 =c(Po), P? =g(P1), %
Pt, P2, p3 =g(P2) , q,
P2, PJ, P, = g(PJ ), q2
where q. is obtained using (2.27).
In Steffensen's method, l/o, q1 are used as initial values for the fixed-point iteration in the following
manner.
p/l, Pt(OJ =C(Po(O) ), p /OJ =g(pt> ), l/o(O)
p/> =q/>, Pt(I) =g(p/>),p/l =g(p.<1>), q/l
), p}2l = 8 (P/21), q/ 1
Po(2) = q/1, p/ 2>=8 (Po<2>
Amd soon.
Chapter 2: Solutions of Equations in One Variable <§'.>
Example 2.11
Consider the fixed-point problem shown in Section 2.7. I. Table 2. 7 shows the results of fixed-point
iteration with Steffenscn's acceleration.
0 I l.615952055 l .815873924
1 1.911945689 1.899376500 l.895821228
2 J.8944 I8955 l.894421644 l.894422402
3 1.8944227 1.8944227
•
_J
Systems of linear equalions arise in solving real-world problems. These type of equations also arise
in solvi ng systems of nonlinear eqlllations as well as boundary value and initial value problems.
In this chapter. direct methods of solving systems of linear egualions will be presented.
where x,, x 2 , •••, x. are the unknowns and a 11 , a,2' ..., a,,,, are the respective coefficients.
We can solve the system shown in (3. I) by reducing it. The steps taken to reduce a system of linear
equations are a combination of the following three operations.
I. Interchange of two equations
Il. Multiply an equation by a nonzero constant
m. Multiply an equation by a nonzero constant and add that to another equation
~ CHAPTER 3: Solutions of Linear Systems of Equations
x,
X2
x= (3. 12)
x.
and
b,
b=
b2 (3. 13)
b,.
A is a square matrix if 111 = 11 , otherwise it is a rectangular matrix. In most cases, we will be dealing
with square matrices.
a,,-' a n2 a.,, b.
R' ➔ R +(-~)R
l 3
Gu
I
AJthough the row operations above will modify the elements of the augmented matrix, we will keep
the same notations for the sake of convenience. The reduced augmented matrix is shown below.
0 0 n2 ann bn
Use a12 as the pivot element to eliminate a 32 , a 41 , .• •, a. 2 from the respective rows using the following
row operations.
and soon.
[A,b]=
0 0
~ CHAPTER 3: Solutions of Linear Systems of Equations
Example3.1
l
Consider the system of linear equations in (3.8). The augmented matrix for this system is
2 -4 5 36
[A,b]= - 3 5 7 7 (3.15)
[ 5 3 - 8 - 31
2 -4
[A,b]= 0 - 1 14.5
[
5 36
61
0 13 - 20.5 - 12 1
l (3. 16)
In essence, after the above row operations, the linear system in (3.8) is now reduced to the system
shown in (3.17)
2x1 - 4x 2 + 5x3 = 36
- x~ + l4.5x3 =61 (3.17)
l3x2 - 20.5x3 = - 12 1
Perform the following row operation on the augmented matrix in (3. 16).
R; ➔ R 3 + 1 3R 2
CHAPTER 3: Solutions of Linear Systems of Equations <&>
l
The resulting augmented matrix after the above row operation is
[A,b)=[ ~~
0 0
14.~ 36
61
168 672
(3.18)
R'
"'
➔ R,. +(-a,.i,)R
a
l:t
t
(3.20)
The multiplier is
If the pivot e lement au « a,,.., the multiplier M,.. becomes very large and, therefore. the round-off
errors in the elements of the kth row get magnified. To prevent this, before a row operation, the row
(column) with the current pivot position and all rows below it (columns on the right-hand side of it)
can be searched to select the element with the largest absolute value and necessary row (column)
ex.changes can be done to bring the element with rl1e largest absolute value in the pivot position, This
is generally termed as partial pivoting.
Example3.2
Consider the following system of linear equations shown in (3.2 1). We will first solve the system
using Gauss elimination with no pivoting. We will use four-digit decimal floating point arithmetic
with rounding.
0.02x1 - 6x2 + 3x3 = 24.306
Sx, + 4.56x1 + 0.563x3 = - 7.018 (3.21)
0.367.r, + 4.23x2 + l3x3 = 35.881
We write the augmented matrix as
<B> CHAPTER 3: Solutions of Linear Systems of Equations
(A, b]=
0.02 -6 3 24.306
5 4.56 0.563 - 7.018
[ 0.367 4.23 13 35.881
l
l
The reduced augmented matrix becomes
0.02 -6 3 24.306
[A,b)= 0 1505 - 749.4 -6084
[ 0 0 14.9 52.28
Using backward-substitution, the solution is x3 =3.509, x 2 =-2.295 and x, =0.45. The exact solu-
tion is x 3 =3.5, x 2 = - 2.3 and x, = 0.3. Note that the solutions for x 1 and x2 are close to the exact
solution. However, the solution for Xi is 1.5 times the exact solution and clearly UJ1acceptable for any
practical use. The rounding error has impacted the solutions of both x3 and x 2 • But the rounding error
became even further magnified when we solved for x 1 due to a relatively small pivot element 0.02.
Let us now apply partial pivoting in reducing the system (3.2 1). We will again use four-digit decimal
floating point arithmetic with roUJ1d ing.
Scan the elements in U1e first column of the augmented matrix. The element with the largest absolute
vaJue is in the second row. Let us, therefore, interchange rows I and 2.
The augmented matrix after the row interchange is shown below.
[ A, b) =
5 4.56 0.563 - 7.018
0.02 -6
[ 0.367 4.23
3 24.306
J3 35.881
l
l
Eliminate the coefficient of Xi in rows 2 and 3 using a 11 = 5 as the pivot elemeut. The reduced aug-
mented matrix becomes
Examining the elements in the second colwnn, from row 2 to 3, we find that row 2 has U1e element
with the largest magnitude in the second colwnn position. Therefore, no row interchange is neces-
sary. We use a 22 =-6.018 as the pivot element to eliminate U1e coefficient of x 2 in row 3.
After elinlinating the coefficient of x, in rows 2 and 3 and further el.inninating the coefficient of x 2 in
row 3. the reduced augmented matrix becomes as following.
[A,b) = 58
[ 0.367
0.2 670.245
4.56
4.23
3 -4211.984
0.563
I 30
- 9.358
428.46 I
l
The reduced augmented matrix with no pivoting is shown below.
[A,b)=
0.2
[ 0
670.245 3
0 - 194366.49 - 869.437
0 129.712
-4211.984
1221466.002
828.656
l
Using bachvard-substitution, x3 =6.388, x 2 =-6.313 and x, =0.543. The exact solution is x 3 =3.5,
~ = - 6.3andx1 =0.3.
Now, use partial pivoting. Scan the first column of the augmented mattrix. The elemem with the larg-
[ A, b] = 0.2
[ 0.367
4.56 0 .563
670.245
4.23
- 9.358
3 -421 l. 984
130 428.461
l
est absolute value is in row 2. Therefore, interchange rows l and 2. The resulting augmented matrix is
58
[ A, b] =
[ 0
0
4.56
670.231
4.203
0.563 - 9.358
2.998 -4211.956
129.997 428.517
l
Eliminate the coefficient of x, in rows 2 and 3. The reduced augmenued matrix becomes
58
Examining the elements of the second column, from row 2 to row 3 , we notice that row 2 has the
element with the largest magnitude. Therefore, no row interchange is necessary. We now eliminate
the coefficient of x 2 in row 3 using ,a22 as the pivot clement.
l
After eliminating the coefficient of x , in rows 2 and 3 and further eliminating the coefficient of x 2 in
row 3, the reduced augmented matrix becomes as following.
Using backward-substimtion, lhe solution is x 3 = 3.49 1, x 2 =-6.3 and x , = 0.3. The solution obtained
using partial pivoting is close to the exact solution of x 3 = 3.5, x 2 = -6.3 and x, = 0.3. ■
Both rows and columns can be searched for the element with the largest absolute value and necessary
row and column interchanges can be done to bring that element to the pivot position. This approach
is called complete pivoting. It should be noted that although neither row interchanges nor column
interchanges change the solution to the linear system, column interchanges do change the placement
of the solution to the unknowns. For example, if you interchange -columns I and 2 in the linear
system shown in (3.2), the order of the solution for the unknowns will be - 2, I and 3 instead of I ,
- 2 and 3.
2 -4 536]
[A,b]= 0 - 1 14.5 61 (3.22)
[ 0 0 I 4
R; ➔ R, +(- 5)R3
l
2 -4 0 16
[A,h]• [ 0 -1 0 3 (3.23)
0 0 I 4
Now, perfonn the following row operation.
R; ➔ R, + (-4) ~
l
2 0 0 4
[A, b]•[ 0 - ) 0 3 (3.24)
0 0 I 4
CHAPTER 3: Solutions of Linear Systems of Equations 0
The off-diagonal elements of the coefficient matrix segment of the augmented matrix become zero.
Frnm (3.24), the reduced equivalent linear system of equations can be thought of as following.
2x1 =4
- X2 =3 (3.25)
X3 =4
The unknowns can be solved directly from the reduced equations as .x1 = 2. x2 = - 3 and x 3 = 4.
a., G 41 0 43 a,.
A has its inverse A_, that can be written as
Performing the matrix multiplication and equating the corresponding elements. we can write the
folJowing systems of linear equations.
We have four systems of linear equations. Each system has four unknowns. Ald1ough die tmknowns
are different, the coefficient matrices of the four systems are the same. We can dierefore apply die
same row operations in doing Gauss elimination to reduce die four systems into the same triangular
form. Only the right-hand constant lerms are diffcrenL We can write an extended augmented matrix
as shown in {3.31) to apply Gauss elimination.
After the reduced triangular form oif die extended augmented matrix , we can determine die elements
of the inverse in the following manner.
(3.32)
(3.35)
(3.36)
C.u (3.37)
(3.3 8)
(3.39)
0 .1
g.3 = - (3.40)
0 .,
0-n - o3,g,3
(3.41}
G33
a21 - ang33 - a.1,Co (3.42)
(3.43)
(3.44)
(3.45)
a:u
au - 0 23834 - ~g.. (3.46)
{122
As discussed before, the system of linear equations shown in (3.48) can be written as
Ax=b (3.49)
<e> CHAPTER 3: Solutions of Linear Systems of Equations
au an a,3 a,.
a2, G22 ~ a24
A= (3.50)
G31 1½2 Ct33 G34
x,
X2
x= (3.51)
X3
x,
and
b,
bl
b= (3.52)
b3
b,
Example 3.3
Consider the system of linear equations shown in (3.53).
2 -3 5 2
1 4 -2 1
A= _,
-3 l 2 ~
4 - 2 - .I - 1
CHAPTER 3: Solutions of Linear Systems of Equations <B>
the constant term column vector is
3
5
b=
-2
9
2 -3 5 2 1 0 0 0
1 4 -2 1 0 I 0 0
-3 I 2 3 0 0 I 0
4 -2 - I -1 0 0 0
Do the following three row operations to eliminate the first element from rows 2 to 4.
R; ➔ R+(-½)R,
2
R; ➔ R +(-~ )R,
3
R~ ➔ R. +(-1)R,
We will use 4 digits after decimal for our calculations. The extended augmented matrix becomes
2 -3 5 2 L O O 0
0 5.5 -4.5 0 ~.5 1 0 0
0 - 3.5 9.5 6 1.5 0 I 0
0 4 - 11 - 5 -2 0 0 I
Do the following two row operations to eliminate the second element from rows 3 and 4.
2 -3 s 2 I 0 0 0
0 5.5 -4.S 0 ~.5 I O 0
0 0 6.6364 6 1.1818 0.6364 1 0
0 0 - 7.7273 -5 - 1.6364 ~-7273 0
<e) CHAPTER 3: Solutions of Linear Systems of Equations
Do the following row operation to eliminate the third element from row 4.
R' ➔ R
• •
+( - 7.7273)R
6.6364 3
2 -3 5 2 I 0 0 0
0 5.5 --4.5 0 -0.5 I 0 0
0 0 6.6364 6 1.1 818 0.6364 I 0
0 0 0 1.9863 - 0.2603 0.0137 1.1644 1
Using the expressions from (3.32) to (3.47) we can find the elements of the inverse of the coefficient
matrix.
2
- )
x=
-2
3
•
3.7 Solution by Cramer's Rule
Consider the following set of linear equations.
a 11 x1 +a 12x2 +a0 x3 = b1
a11 x1 + a11 x1 +a2lx3 = b1
0 J1xt + 0 J2x1 + 0 u·':., = bl
CHAPTER 3: Solutions of Linear Systems of Equations <§>
The system of equations above can be written in matrix form as:
Ax= B
l
where
a., 12 3
A= a,, aa.22 a
a~
[ a,, a32 a 31
*
··[ :l~ •·[:l
If D 0, then the system has a unique solution as shown below.
D, X _D
_ 1 t _D
_ 3
,x,= - , 1- and + 3-
D D D
where
where
A·[-l : j l
· [ : lMd •·[_:;]
2 -4 5
D= -3 5 7 =-336
5 3 -8
36 -4 5
D, = 7 5 7 = - 672
- 31 3 -8
2 36 5
D, = -3 7 7 = 1008
5 - 3 1 -8
2 -4 36
D, = -3 5 7 = -1 344
5 3 - 31
D, -fJ72
r =-=--= 2
.' D - 336
D, !008
r2 = - = - - = -3
• D - 336
D, -1344
r =-=--= 4
.' D - 336 •
3.8.2 LU factorization
Assume A can be factorized as A= LU. A system of linear equations tben can be expressed as
LUx= b (3.54)
[,, L,, 0 0 u ,, u ,2
l
a l2 au ljll
A= '½1
a ll
a-n tin
a 32 a 33
} L•[ ½, ½1 ½2
½2 ½3
lmd U•[
0 0
0
U22
0
v~,
U 33
]·[ ~
. ][ ~ 0 0
l
011 a,2 a,J U,2 U13
[ Oi,
a3, a.,.1
a"ll 0 23
0 33 L 31
L22
L32
0
L 33
U21 U23
0 U33
0 23
0 33
l[ =
L,,u,,
Li, V11
L 3,U11
L, 1U,2
L11U,1 + LnV22
L 31U ,2 + L32U22
½1Un +lnUn
L,,Ul.l
L 11U 12 =a 12 and
L11U 13 = a 13 .
<e:> CHAPTER 3: Solutions of Linear Systems of Equations
In the above, we bave 9 equations but 12 unknowns. We can solve for 9 unknowns if we can assign
some convenient values to 3 elements. In Crout's method, the diagonal elements of the upper trian-
gular matrix U are set to land in Dolinle's method, the diagonal elements of the lower triangular
matrix L are set to 1.
Crout's method:
Do little's method:
Example3.5
Use LU factors to solve tbe system of linear equations shown in (3.55).
2x1 + x 2 + 3x3 = 13
X 1 + X2 - 2X3 =7 (3.55)
3x1 - 2x2 +4x3 = - 5
CHAPTER 3: Solutions of Linear Systems of Equations 0
Solution
The system of equation can be written as
Ax=b
where
A=LU
Let us first solve the system using Crout's method.
Therefore,
0
0.5 ~
- 3.5 - 25
] and U = [ 0
0
1 0.5
] -7
0
1.5 l
LUx= b
Ly= b
wlnere Ux=y.
Using forward-substiturion,
u:l·l .:n
<e:> CHAPTER 3: Solutions of Linear Systems of Equations
Now, using Ux = y
Using backward-substitution,
L 11 = L, L22 = I, ½ l =I
½, =1.5, L32 = - 7
l
Therefore,
0 0
L=[ O.~ 1 0 0.5I - 3.53
1.5 - 7 L 0 - 25
LUx=b
Ly=b
where Ux = y.
Using forward-substitution,
CHAPTER 3: Solutions of Linear Systems of Equations <S>
Now, using Ux = y
u,-[
Using backward-substitution,
2 I 3
0 0.5 - 3.5
0 0 - 25
Xi
l[ J·[
X2
X3 in
•
3.8.3 Elementary matrices and LU factorization
EJ.ementary matrices can be utilized to perform elementary row operations (ERO) on a matrix.
Defi11itio11: Any matrix obtained by performing a single ERO on the identity mairix is called an
elementary malrix.
Corresponding to the three ERO, th.ere are three types of elementary matrices.
Type I: PIJ - permute rows i and j in /,..
Type 2: M 1 ( k) - multiply row i of/,. by the nonzero scalar k.
Type 3: Ag (k ) - add k times row i of I. to row J of I,,.
For the 3 x 3 identity matrix, we can write
P, 2 =
[
0
I
0 0
l
0
n-,.-u ~ !J~.·[ ; : il
M,(k)•[ 0k O
1 O
0 0 I
0 l [ : ;J i : ~ l
, M 2 (k)= 0I
0
M,(k)•[
A,,(k) •[ k l
I O 0
0
0 0 1
lA,,(k)•[ i i :n
0 0
I
k
0
I
Pr,e-multiplying a matrix A by an elementary matrix E has the effect of performing the corresponding
ERO on A.
~ CHAPTER 3: Solutions of Linear Systems of Equations
Talce an example.
The most common ERO to reduce a coefficient matrix is adding k times row i of A to row j of A .
Let us multiply row I of A by -0.5 and add that to row 2 of A. The Iiesulting matrix will become
[ ~ -~3.: ]·
-) 3 4
Silllce any ERO is reversible, its corresponding elementary matrix is non-singular and, therefore,
invertible. The inverse of the lhree 3 x 3 elementary matrices can be obtained in the following manner.
l O O
0 I 0
0 0 1
l
CHAPTER 3: Solutions of Linear Systems of Equations <8>
Therefore.
P,,-' • [ ! I 0
0 0
0 I
l
P,t =P,2
Pn ?.i/ = l 3
[
I O O ][ P11
1
0 l 0
0 0 P21
P3o
P,1 P11 ] - [ I O O
Pri P2J - 0 I 0
Pn p 33 0 0 I
l
[~:~ ~ ]·U!n
Equating the corresponding coefficients,
P21 = 0, P12 = 0, Pn = I
JJ31 = 0, Pn = l , p 33 = 0
l
Therefore,
0 0ll
0
l 0
<fJ> CHAPTER 3: Solutions of Linear Systems of Equations
Similarly,
Therefore,
0 0
M,(kf' =
M, (kf'
[ 'i'~
=M, (1/k)
I 0
0 l
l
M2 (k)M 2 (kf' =15
CHAPTER 3: Solutions of Linear Systems of Equations <8)
Equating the corresponding coefficients,
Therefore,
l
0 0
M,(kf' =[: ll/k 0
0
1
M 1 (kf =M 2 (1/ k)
Similarly,
M, (kr' =[ i 0
]
0 1/ k
0
0
l
M3 (kf' =M3 (1/ k)
1
A12 (k)A12 (kf =13
(: ! ~ l[ ~: :: :: ]=(i ! ~ l
~ ]=l : ! ~ l
[ .. · :: ,~,+~ ,~. +~
Therefore,
~.1,r' ·(-i !n
A12 (kf' = A12 (-k)
Therefore,
Aul'r' •[ i _;:]
An{kf' =A13(- k)
Similarly,
Alil ERO can be performed on a matrix by pre-multiplying the matrix by a corresponding elementary
matrix. Therefore, all EROs that are performed in Gaussian elimination to reduce the coefficient
matrix to its row echelon fonn (REF) can be achieved by pre-multiplying A by a sequence of
elementary matrices.
CHAPTER 3: Solutions of Linear Systems of Equations <8>
where R denotes an REF of A.
Since the unique reduced row echelon fonn (RREF) of a non-singular matrix is the identity matrix,
E,£1E3· ··Ek A= 1.
(3.56)
A-I =E,E1E3·-- Ekl .
Equation (3.56) shows that A- 1 can be obtained by applying the same sequence of ERO to I . that
reduces the non-singular A to its unique RREF.
LU Factorization
EJ.emcntary matrices can be utilized to reduce a non-s.i ngular matrix to an upper triangular matrix
l
much the same way a REF of a matrix is obtained utilizing elementary matrices.
4 -2 3
Let us reduce A = 2 7 5 to an upper triangular form using elementary matrices.
[ -I 3 4
The given matrix can be reduced to an upper triangularfonn using the following sequence ofEROs.
7/23
19/4
l
➔ An( - 5/16) ➔ [ l
04 - 28 7/ 23
0 0 117/32
In this section. we limit our discussion to non-singular matrices that can be reduced to triangular form
withom needing any row permutation. For such cases, a matrix can be reduced to upper triangular form
utilizing only Type 3 row operations. In addition, we restrict the Type 3 row operations in such a way
that we utilize ith row to obtain a zero in a row beneath ith row. With this restriction. all elementary
matrices corresponding 10 the Type 3 row operations that we will use will be lower triangular matrices.
Matrix A, therefore, can be reduced to an upper triangular matrix in the following way.
E,E1E3···EkA=U
The inverse of a lower triangular matrix is another lower triangular matrix, and the product of two
lower triangular matrices is also another lower triangular matrix. Therefore,
A=LU
Solution
Using the previous results,
7/23
117/32
l
l
where
ol o0
- 5/16
-I 17/32
7/23 l
The inverse of the elementary matrices E,. E 2, £ 3 are
I 0
E,-• = A12 (1/2) = 1/ 2 l
[
0 0
E/ =A13 (- l/4)=[ ~
- 1/ 4
CHAPTER 3: Solutions of Linear Systems of Equations 0
E/ = A13 (5/16)=
( I
0
0
I
0 5/16
n
nl l
0 l l 0 0 l 0 0
L = £,-•£;';;,-•= [ 1/ 2 1 0 1 0
)[ 0 I 0
0 0 -1/ 4 0 l 0 5/16
n
I 0
L=[ - 1/ 4 1/ 2
5/ 16
A=[ - 1/I/;4 5/ 16
0
1
nl ,l4 -2
0
0
8 7/ 2
0 117/ 32
•
By observing the lower triangular matrix, we notice that the elements beneath the leading diagonal
are. the multipliers by which a specific row was multipl.ied and the result was subtracted from row i
to obtain a zero at ij location in developing the upper triangular matrix. For this example,
m21 = 1/ 2, m3 1 = - 1/ 4, m 32 = 5/ 16.
We may, therefore, save these muluipliers when the upper triangular matrix is developed and then
obtain the lower triangular matrix by directly using the multipliers instead of mnltiplying the inverse
of the elementary matrices.
[,, ]-[~. 0 0 ½1
l
0 12 a, 3 L" L 3,
a 2l
~ I
{111
a 32
{113
an
- ½1 ½2
½1 4- ½J
0
][ 0
0
L21
0
½2
L 33
<£9 CHAPTER 3: Solutions of Linear Systems of Equations
Since A is symmeLric,
a3, =au
a32 = 0-n
L ll -- vuu
~a t L 21 -- -
"n , - 0 13
, "-'ll - -
L,. L,,
ll11 - Li,"31
L 22
. Ja - 1
L }.} = }.}
1-,
k=I ( L J.k)
2
Example3.7
Solve the system of linear equations using Cholesk:i's factorization.
4x1 +2x2 + 3x3 =5
2x, +6x2 + x3 = 13
3x1 + x2 + 7x3 = - 2
Solution
The system can be arranged in mabrix fonn as
Ax=b
wlnere
The coefficient matrix is symmetric positive definite. Therefore, Choleski's factorization will work.
L11 =2, L 21 = l, 4 1 = 1.5
4 = 2.236, ½2 =-0.224
CHAPTER 3: Solutions of Linear Systems of Equations <8>
Jl
0
L=( '. 2.236
1.5 - 0.224 2
LLrx=b
Ly= b
where LTx = y.
,J ][ l·l ~
n
2 0 Y,
Ly=( I 2.236
1.5 -0.224
Y2
.V3
Using forward-substitution,
l
2.5
[
Y1
Yi
)'3
]=( 4.696
- 2.168
Now, using Lr x = y
L',=[
2 I
1,
0 2.236 -0.224
0 0 2.168
l[ ]=[
X1
X2
X3
2.5
4.696
- 2. 168 l
Using backward-substitution,
XI
[ ]=( _i]
"~
X3
•
3.8.S LDP factorization
A symmetric positive definite matrix can be factorized into the form LDLT, where L is a lower
triangular matrix with diagonal elements being I, D is a diagonal matr ix and LT is the transpose of L.
A=LDLT
<e) CHAPTER 3: Solutions of Linear Systems of Equations
[,, d11Li,
l
a,2 0 13 0 0 dll d11½1
a,, 0 23 ½, l 0 0 dn d2242
]·[
a "l.1
a ll 0 12 a ll ½1 4i ][ 0 0 d,1
The elements of the lower triangular matrix L and the diagonal matrix D are:
d 11 =a 11
L, = a, 2
_, i
l II
where
A=[ ~3 ! ~ ) b=[
I 7
and I~ ]
-2
-, ., 2 2
d33 =an - du½i- - d22 L 31 - =7 -4 x(0.75) - 5x(- 0.1) =4.7
LDLTx= b
l( i l·( ~n
0 0 4 0 0 0.5 0.75 X1
( 0.5I I 0
0.75 --0.J 1 ][ 0 5 0
0 0 4.7 0
l --0.l
l l[ X2
X3
Ly= b
l·( ~n
0 0 Y,
( 0.5I I 0 Y2
0.75 --0. J 1 ]( )'3
<e> CHAPTER 3: Solutions of Linear Systems of Equations
Using forward-substitution.
Dz=y
Using backward-substitution,
•
3.8.6 Solution by QR factorization
The QR factorization, also called QR decomposition, is a factorization of a matrix into an orthogonal
matrix and a triangular matrix. If A is a real square matrix then it cani be factored as A= QR. where
Q is an orthogonal matrix and R is an upper triangular matrix.
A real square matrix witb ortbonormal colwnns is called an orthogonal matrix. The columns (rows)
are mutually perpendicular witb respect to each other. An orthogonal matrix is invertible with the
property that
Therefore,
0 Rn R23
0 0
0 0 0 0 R,,,,
For i = l, 2, 3, ... , 11
a,rq, a/q, 03
T
q, a Tq
• I
T T
0 a/q2 aJ q2 a. q2
0 0
0 0 0 0 a" Tqn
Example3.9
Consider the system of linear equarion,
2x1 - 3x 2 + 5x3 = - 3
+ 4x2 - 2x3 = 2
X1
- 3x1 + X 2 + 2x3 = - JI
Ax=b
where
A=[ - ~3 -:I -~
2
land b=[ -; ]
- 1l
QRx = b where A = QR
Q=
0.5345 -0.4645 0.706 1
0.2673 0.8855 0.3802
[ -0.8018 -0.0145 0.5974
l
R=
[
3.7417 - l.3363 0.5345
0
0
4.9208 -4.1224
0 3.9648
l
Qz = b where Rx = z
l
[ -0.8018 -0.0145 0.5974
7.7506
z= 33241
[ - 7.9296
l ll l
Now Rx =z
3.7417 - 1.3363
0.5345
0 4.9208 -4.1224 x,
X1 = 7.7506
3.3241
[ 0 0 3.9648 x - 7.9296
3
Using backward-substitution,
•
Problem Set 3.1
1. Solve the following sets of l.inear equations by Gaussian elimination, Gauss-Jordan elim.ina-
tion, Cramer's rule and mattix inversion.
a. 4x 1 - x2 + x 3 = 8 b. x, - x2 + 3x3 = 2
2x, +5x2 + 2x3 = 3 3x, - 3x2 + X3 =- I
x , +2x 2 +4x3 = 11 =3
1 l I
C. - X
1
+ - X, + - X3 =9 d. 2x, - 3x1 + x3 = 6
4 5 - 6
X1 + X1 - X3 = 4
1 I I
- x, +- x, + - x3 = 8 - X 1+ X2 - 3x3 =5
3 4 - 5
I
X1 + X 2 + 2X3 = 8
2
e. 2x, + 3x1 - x3 = 4 f. 2x, - x 2 + x'.l = - I
X 1 - 2x2 + X 3 = 6 x 1 + Xi + 3x3 = 0
x, - 12.xl + 5X3 = IO 3x, + 3x2 + 5x3 = 4
400 - 201
[ - 800 401
][.x']=[
.X2
200]
- 200
The system can be solved by using previously covered methods and the solution is x 1 = - 100 and
X-i = - 200.
Now, let us make a slight change in one of the elements of the coefficient mate.ix. Change A11 from
400 to 40 I and see bow this small change affects the solution of the following.
401 - 201
[ - 800 401
][x•]=[
.X2
200]
- 200
(3. 57)
The notation max { } denotes the maximum element of the set. The fonnulation shown by Equation
(3.57) is also called the infi nity norm of the vector x. Note the following properties of infinity nonn.
Note that the expression for IIAII involves summing the absolute values of elements in the rows of A .
Example 3.10
Consider the following Linear algebraic system.
(3.60)
Condition Number
Let us investigate first, how a small change in the b vector changes the solution vector. x is the solu-
tion of the original system and let x + l!.x is the solution when b changes from b to b + l!.b.
Then we can write
A(x+ I!. x) = b+ l!.b
or, Ax + AA x = b + Ab
11A-'I!.~ 1~IIA-'11·I ~~ I
i.e., II!!. xii~IIA-'11·II!!.~ I (3.61)
~ CHAPTER 3: Solutions of Linear Systems of Equations
Again using Equation (3.60) to the original system, Ax = b we can write that
IIAxll~IIAll·l~II
i.e., l~ll~IIAll·l~II
ll&xll <IIA-'ll·11&~1
lvtll·l~II- 11h11
. 1~ 11 lvtll·IIA-'ll·ll&bll
J.C. , ~ ~ 11~1
or ll&xll ~IIAll·l~-,11·1~~1
. 1~11 llbll
or ll&xll <K(A)- l~bll (3.63)
' llxll - llbll
where K (A) is called the condition number of the matrix:A and is defined as
Ax= Ax+A&x+&Ax+M&x
(3.64)
Example 3.11
In Example 3.10,
I I I
I - -
2 3 II
I I I l
- -
H"= 2 3 4 n+l
1 I
II II+ 1 11+2 211 - J
Ill-conditioned matrices including Hilbert matrices arise in applications involving least squares
techniques and in discrete solutions of some partial differential equations.
Scaling
Large condition nwnbers can also arise from equations that are in need of scaling. Consider the
following coefficient matrix which corresponds to one 'regular' equation and one ' large' equation.
A= [ I -1]
1000 1000
I AI=max{2,2000}= 2000 and IIA-'11=max{ 0.5005.0.5005}. The condition number is: K ( A)=
2000x0.5005 = 1001
Scaling (called Equilibration) can be used to reduce the condition number for a system that is poorly
scaled. If each row of A is scaled by its largest element, then the new A and its inverse become
400 - 201]
A= _ whose condi tion number K{A) is 3603 expect to lose 3 decimal places in
[ 800 401
accuracy.
IEEE standard double precision numbers have about 16 decimal digits of accuracy, so if a matrix bas
a condition number of 1010• you can expect only six digits to be accurate in the answer. An important
aspect of conditioning is that. in general, residuals R = Ax - b are reliable indicators of accuracy
only if the problem is well-conditioned.
l
1. Compute the condition number of the following matrices.
11 2 3
4 15 6
7 8 19
21 31
51 61
29 49
l
R TECH I
8 tlN
N-- -E-A ifsv~
Although it may appear that direct methods provide exact solutions, rounding and truncation errors
accumulate quickly due to finite digit arithmetic operations and the solutions obtained become far
from exact. Instead, iterative techniques could be used to obtain solutions that are not exact but
are very close to lhe exact solutions. Iterative techniques are relatively straight forward in tenns of
computation and its implementation.
In this chapter, we will first discuss two iterative techniques that can be applied to linear as well
as non-Linear systems of equations. An iterative technique to solve an n x n Linear system Ax= b
starts with an initial approximation x<0l to the solution x and generates sequence of vectors x(Kl that
converges 10 the solution, x.
Convert the set Ax = b in the form of x = Tx +C. Each equation in (4.1) can be rewritten in tenns
of one of the unknowns in the following manner.
_ a, a 13
x 1 - - -2 x2 - -x -
a,,.
···- - X +-b,
3 11
a11 a11 ° 11 °11
ci., 1
X 2 = - --- .X 1
Gu
- -x
~. b,
-· · ·- -X. +--
3
a22 an °22 a22
x, -- -G-x
31 a ,2 a,,. b3
(4.2)
1 - - x 2 -· ·· - -x. +-
a1l an a11 a 3J
The kth update of the unknown vector x<•>can be obtained using x1•-•>
.
x/kl = - I, ayx/ 1-1)+!!I_ j= 1, 2, 3... . , II (4.4)
i-=-• au au
J,J
Example4.1
Consider the following set of linear equations.
12x1 - x 1 +2x3 +x, =9
- 2x1 + l lx 2 + x 3 - 3x, = 15
(4.5)
x, + x 2 +9x3 +x, =- 5
2X1 + x2 - 2X3 +8x4 = 16
I I I 3
- x(l) -- x(l) - -(J) + - =0.58333
12 6 12 4
2 I 3 IS
x/> Jl = - x(l) - - x(I)+ - x( I) + - = 1.72727
II LI II
I l
x 3() = -- x(I) - - x(l)
L I s
-- x(l) -- =--0.&8889
9 9 9 9
+ 2= 1.87500
After the first iteration, x(•) = [0.58333, 1.72727, --0.88889, 1.87500)7. With x<•>. we now proceed to
find xl2l in the following manner.
• (2) -
.Al -
_!_ x (ll _ _!,x (I) _ _
I x<•> +~
2 3
12 6 12 • 4
X4
12> _ I (1) E (1)
- - - X1 - - X 2 + -I x,(1) +2
4 8 4
(2) - I l I 3
XI -
- x (l.72727) -- x(--0.88889)- - (1.87500) + - = 0.88584
12 6 12 4
2 I 3 JS
x2 (2 l = - x (0.58333) - - x(--0.88889)+ - x (1.87500) + - = 2.06187
II II II 11
Similarly, xt2>, x l3l etc. are generated and presented in Table 4.1.
~ Chapter 4: Iterative Techniques for Solving Linear and Non-Linear Systems
k X (kl X / kl X (kl X Ck )
I l 3 4
x, (•l = - x,
I (k- 1) I (k- 1) l (k- 1)
--x3 - -x4 +-3
12 - 6 12 4
I
X
2
(I) _
- -
2
] ]
X
I
(k- 1)
- -
(1- 1)
X3 +-3 .r4(l- 1) +-15
11 11 ll (4.6)
(k) _ ] (k- 1) ] (k-1)
x, - - - x, - - x,
· 9 9 ·
(k) - I (k- 1) l (k- 1) l (k- 1) +2
~ - --~ --~ +- ~
4 8 4
• (k) -
-'"I -
•• (I) -
-'"I - -1 x,(o) --x
l co1
3
l
- -x 4
(oJ
+-3
12 - 6 12 4
I to1 +-3 x (OJ +-15
- -x 3 4
11 11 11
--I x (ol 5
--
9 • 9
1 1 I 3
xi'1= x( IJ - x(J) - (1) + = 0.58333
4
12 6 12
x/>= 2.. x(0.58333) -.!.x(L) +2- x(I) +~=l.65 152
11 11 11 II
x/1=-¼x (0.58333) - ¼x(J.65l52) - ¼x (l) - %=--0.91498
(2) - I I I 3
XI x(I .65I52) - x(-0.9I498)- (1.41898) + =0.92188
-
12 6 12 4
2 I 3 15
xt>= - x(0.92188) - -x (-0.91498)+- x (I.41898) +- =2.00143
11 II II II
xt> = - .!.x(0.92188) - .!.x(2.00143) - .!.x(I.41898) - ~=- 1.03803
9 9 9 9
x/> = - ¾x (0.92I88) - ½x(2.00I43)+¾x(- J.03803) + 2 = 1.25985
xt.t' X (k l X (k) X ( k)
k I 2 3 4
Taible 4.2 clearly shows the advantage of the Gauss-Seidel iterative technique over Jacobi iterative
technique.
A strictly diagonally dominant mairix is nonsingular. A symmetric diagonally dominant real matrix
with nonnegative diagonal entries is positive semidefinite.
Chapter 4: Iterative Techniques for Solving Linear and Non-Linear Systems 0
If the coefficient matrix A of a Linear system is strictly diagonally dominant, then for any choice of
x<0>both Jacobi and Gauss-Seidel it,erative techniques produce sequences { X (k)
the unique solution of Ax = b. •=<>
that converges to r
4.4 Iterative Techniques for Non-linear Systems
At this point we would like to utilize the two techniques to solve non-Linear systems of equations.
Consider the following system of non-Linear equations.
l5x 1 +x; - 4x3 =Il4
x~+ l 0x2 - x 3 = - ll (4.8)
3x, + x; - 25x, = - 19
We will first utilize an iterative technique similar to the Jacobi iterative technique (fixed-point
iteration for multiple urumowns) to solve the system. The first step is to rewrite the system in the
folJowing manner. There is no rule: as to which equation should be used for x, and which one for
Xi· The choice is made as a matter of convenience and to circumvent the situations where an equa-
tion may not have an unknown Linked to it.
(k) -
X1 - --
l ( .x,
. (k- 1) )2 + -4 X (k- 1) + -I 4
]5 - 15 3 15
2
(k) _ I ( (t- 1)) l . (t - 1) 11 (4.9)
X, - - - Xi + - .X3 --
- IO JO JO
X3<•>-_ - 3 X 1(t- 1) +- l ( X,<•-•> )3 +-l 9
25 25 - 25
k X Ctl X CtJ X / kl
j 2 J
X
(I) -
- - -
l ( X. (I) )2 + - I X. (k- 1) - -11 (4.10)
2 IO I 10 3 10
We take an initial approximation of x<0> = [ 1, I, 1 f and the corresponding iterates are shown in
Table4.4.
k X (kJ X (l J X ( kJ
I 1 3
In general, the Gauss-Seidel iterative technique requires less number of iterations compared to the
Jacobi iterative technique.
x,(k- 1)
x. (k- 1)
and
h (x,,x1 , x3 ) = x: - 2x,x3 - 4
<@> Chapter 4: Iterative Techniques for Solving Linear and Non-Linear Systems
,
[ ,,: + ,,,,, - x, x ·I - x,
l (X)= e''
- 2x1
e-'1
2x1
- I
- 2x1
l
Make an initial guess as:
x<•>=
-0.90000
1.07459
[ 0.47459
l
Chapter 4: Iterative Techniques for Solving Linear and Non-Linear Systems ~
F( x(I>) =
6.56855
2.86078
[ - L.99098
l
1(x(I))=
0.02114 0.81000 0.90000
0.40657 2.9288 - L.00000
[ -0.94919 2. 149 19 1.80000
l
2.04925 0. 13152 -0.95156
1(xC•J r = 0.06002 0.24641 0.10688
[ J.00896 -0.22485 -0.07384
l
xl 2
>=
-0.90000
1.01459
[ 0.47459
l[ -
2.04925 0. 13 I 52 -0.95 156
0.06002 0.24641 -0.10688
I.00896 -0.22485 -0.07384
l[ 6.56855
2.86078
l
l
- I.99098
-16.63141
x<2> = 0. I 8822
[ - 5.65656
l
Similarly,
- 10.21778
x<3>= - 2.49499
[ - 2.0318
x<•) =
-7.80536
L.65635
[ 0.42509
l
X= -0. 13180
[ 1.01790
l
Continue until the stopping criterion is satisfied. After IO iterations, the unknowns are:
- 1.95630
accurate within 10-5 _
•
<0> Chapter 4: Iterative Techniques for Solving Linear and Non-Linear Systems
I l I
c. - x, + - x,+ - x 3 = 9 d. 2x, - 3.x2 + X3 = 6
4 5 · 6
x 1 +x 2- x 3 = 4
I J I
- X 1+ -X, +- X = 8
3 4 - 5 3 - X 1 + X2 - 3x3 = 5
I
- x, +x 2 +2x3 = 8
2
2. Solve the following sets of non-linear equations by fixed-point iterative technique, the
Gauss-Seidel iterative technique and Newton's technique.
a. x~ - 3x1x 2+xJ + 4 = 0 b. x~ - 3x2 + x 3 = 9.5
2x1 + Xi - X1X 3 = 7 2x, +xJ - 5x 3 - 1.25= 0
x1x2 + x3' = 3 3x, +x 1 + Xi =5.5
<@>
<€,> Chapter 5: Interpolation
polynomial can be derived using techniques of Lagrange interpolating polynomial and Newton's
interpolating polynomial. Although tbesc two techniques develop the polynomial P. (x) differently,
tbey both result in tile same polynomial expression.
P, ( x) is an approximation of f.
X- X
1 X - Xo
P, (x) - - ~ yo +- - ~ y. (5.2)
x0 - x 1 x 1 - x0
X - X
Atx=x,, L,.0 (x,)= 1 1 Oand li.1(x1) x, - x., I
x0 - x 1 x, - xo
Therefore, P, (x,) = L,.o (x1 ) Yo+ Lu (x, )y, = 0. Yo + I. Y1 = Y,
So, P, ( x) is lhe unique linear function passing through (x0 , Yo) and (x,. y 1). Figure 5.1 shows the
actual function and its first-degree polynomial approximation.
It can be easily noticed from Figure 5.1 tl1at if P, (x) is an approximation oftbeactual function, J(x)
then we did not do a very good job of approximating. However, given only two data points this is the
best we could do. We need to utilize more data points for P, (x) to come closer to the actual function,
f {x). However, more data points do not always provide better approximations.
If we have three data points, (x0 , Yo), (x., y,) and (x2 , y2 ) . then the Lagrange interpolating polynomial
of degree two passing through tl1e three points can be expressed a~
Note that tllere are tbree tem1s on the right-hand side of (4.3) one for each data point, and the degree
of the polynomial is 2.
Chapter S: Interpolat ion ~
Yo =f(x,)
Xo X
Figure 5.1 First-degree polynomial approximation
The general fonn of the Lagrange i11terpolating polynomial passing through 11 +l data points (x0 , y0 ),
(.r1,y1), (x2 ,y2 ), •• • ,(x.,y.) has 11+1 terms on the right-hand side, one corresponding to each data
point. The degree of the polynomial is n.
(5.4)
All we need to do is to express L•.o (x). L,,., (x}, L,,.1 (x}, ... , L,,_,, (x) based on n+ I data points. We
need to construct L,,_t (x) in s uch a way that L,,., (x,) =0 when i 1' k and L,,_t ( x,) =I. This requires
that the numerator of L,,_, (x) contains !he tem1
The tenn (5.5) vanishes at all data points except at x = xt. In order to satisfy L,,_, (x,) = I, the
de nominator of L. _1 ( x) should be equal to the tenn (4.5) when x = x t· Therefore,
(5.6)
The general fom1 of the Lagrange interpolating polynomial can be written as:
• •
P,, (x) =L,L..• (x)yt =L,L.., (x)f(x,} (5.7)
k=O
where
(5.8}
<$> Chapter 5: Interpolation
<l>'(x1 )=(xi - x0 )(xt - x,)• ··(xt - xt_, )(xt - xt••) ··•(x1 - x,,)
L (x)=I1 (x - x,) <l>(x)
•·• r-{J (xi - x,) (x - xt)<I>'(xt)
I#
ExampleS.1
Find the Lagrange interpolating polynomial that approximates a function whose values at three data
points are given below.
(x0 ,y0 )=(2,0.7O71 I)
Solutio11
,
P1 (x) =!, ½_t(x)J(x.)
The three given points were taken from the function, f (x) = ~. The exact value of the function at
x=23is vX
I
f (2.3) = r,:;-,, = 0.65938
v2.3
Am approximation to f (2.3) can be obtained from the second degree Lagrange interpolating
polynomial as:
Pi (2.3) = 0.03908(2.3}2 - 0.32516(2.3) + 1.2011 1= 0.65998
Theorem 5.1
Suppose .r0 , x,, ... , x. are distinct real numbers in [a., b]
and / a real-valued function such that
f E c••' [a, b]. Then for each x in [a, b] there exists a number~ (x) in (a, b) such that
f'"') (~(x))
f(x) - P.(x)=(x - x 0 )(x - x,)···(x - x.) (n+l)! (5.10)
where
P,, (x) is the Lagrange interpolating polynomial of degree 11. ~ (x) indicates U1at it depends on x.
Proof
From Equation (5. I0), f (x ) - P ( x) = 0 if x is one of the node points. If x is not a node point, say
x =t , then define
The functions R(x), Q(x) and <I>(x) arc 11 + I continuously differentiable in [a, b].
Therefore, Q e c•• 1 [ a, b] and Q has n + 2 rustinct zeros in [a, b]. Using Generalized Reile's
Theorem. there exists a number ~ (x) in (a, b) for which Q(.+IJ ( ~ ( x)) = 0.
P,, (x) is a polynomial of degree at most 11. Therefore, (11 + I} th derivative of P,, (x) is zero.
P.t•'l (x) = 0 and, therefore, RC•••l (x) = t<•••l (x)- P,,t"•'l (x) = J<•••J (x).
<1><"•1>(x) = (n +I)!
<J>(n+I) (X)
Q (..+I) (x) = R(n+J) (x) <t>(t) R(t)
Therefore,
ExampleS.2
In Example 5.1, f(x)=t/.Jx was approximated using the second degree Lagrange interpolating
polynomial. At x = 2.3, the Lagrange interpolating polynomial approximated f (2.3) with an absolute
error of 0.00059. Determine the maximum error using Equation (5. IO).
Solutio11
The error for the second degree Lagrange interpolating polynomial can be expressed as
. . J<2+1)(~(x)) . j<3l(~(x))
(,t - x0 )(x - .t,)(x - x2 ) - ~ ~ (x - 2)(x - 2.5)(.x - 3)- ~ ~
(2+1) 1 (3)!
Since j<'l (x) = - (l/2)x-312 , j<2>(x) =(3/4 )X-312 • f' 3>(x) =- (15/8)x-1l2,
the error is - (5/16)(~ (xr )(x - 2)(x - 2.5)(x - 3)
112
Or a = y, - ao
' I
x, - xo
or, a, = Y, - Yo (5.12)
x, - xo
Now examine Newton's equation of a function that passes dlrough duee points ( x0 , Yo), (x,, y,) and
(x2,Y2)·
P2 (x) = <J0 + a, (x - x0 )+ ~ (x - x0 )(x- x,) (S. 13)
<@> Chapter 5: Interpolation
Note that Equation (5. 13) is constructed by adding a third term to the righ1-hand side of Equation
(5. 11 ). The third tenn in Equation (5.13) vanishes both at x0 and x,. Therefore. our first two coeffi.
cients a 0 and a, are still !he same as that found utilizing Equation (5. 1I) for the two-point case. All
we have to do is to find the third coefficient, a 2• In order to find "2, set x = x1 in Equation (5.13).
Newton's equation of a function that passes through four points can be written by adding a fourth
term to the right-hand side of Equation (5.13).
(5. 15)
The fourth term will vanish at all three previous points and, therefore, leaving all three previous
coefficients intact. All we have to do is to find the fourth coefficient a3• We set x = xJ in Equation
(5. 15) and do some algebraic manipulations. Actually, the coefficients can be written in a systematic
manner by using the divided differences of the function values.
The divided difference of f with respect to x1 and x1 +,, called as the first divided difference, is
de noted f [ xi' x1., ] and is defined as
(5. 17)
The divided difference off with respect to x 1, x1., and x1• 1 , called as the second divided difference ,
is denoted f [x1, x1.,, x1• 1 ] and is defined as
The divided difference off with respect to x 1, x,+i• x1+2 and x1+3, called as the third divided difference ,
is denoted f [x,, x,.,, x,.
1 , X 1+3 ] and js defined as
(5.19}
and so on.
From the definitions shown in (5.16) to (5.19} it is clear that the divided difference with respect
to two points is expressed in terms of divided differences with respect to one point, the divided
difference with respect to three points is expressed in tenns of divided differences with respect to
two points and the divided differerace with respect to four points is expressed in tenns of divided
differences with respect to three points and so on. The divided differences can be computed in an
inductive manner.
Omce the required divided differences are calculated, the coefficients of Newton's interpolating pol-
ynomial can be expressed in the fol lowing manner.
a0 = /[x0 ]
a,= f [x x, ]
0,
a2 = f [xo, x,, x2 ]
al = f [Xo, Xi' X1, X3)
and soon.
The prinlary advantage of Newton's interpolating polynomial is that more data points can be
incorporated to generate a higher-order polynomial wi thout repeating the calculations used for the
lower-order polynomial.
A table similar to Table 5. l can be constructed for the divided differences in a convenient manner.
Note that the table could still be extended by two columns on the right to include two fourth divided
differences and one fifth divided differences. The divided differences from the top diagonal become
the coefficients of the Newton's interpolation polynomial.
Using divided differences for the corresponding coefficients, Equation (5. 15} can be written as
~ (x) = f[x 0 ]+(x - x 0 )f[x0 ,x,]+(x - x0 )(x- x,) f [x0 , x,, x 2 ]
(5.20)
+ (x - x0 )(x - x, )(x - .~)J[x0 , x,, x 2 , xJ
Newton's interpolation polynomial of deg ree n can be written as
P,. (x) = P,,. , (x) +(x - x 0 )(x - x,) · ·· (x - x•. , )J[x 0 ,. x,. ·· ·, xJ (5.21)
X f (x) First divided differenc~ Second divided differences Third divided differences
n
:r
Xo f[xo ] ,,
Al
ExampleS.3
Find Newton's interpolating polynomial to approximate a function whose 4 data points are given below.
X f (x}
2.0 0.85467
2.3 0.75682
2.6 0.43126
2.9 0.22364
3.2 0.08567
.i X1 / [xi] / [ x 1,., x1] f [x,_1, x,_., x1] f[x 1-a,•... x1] f [X1...11 ... ,x1]
0 2.0 0.85467
- 0.32617
] 2.3 0.75682 - 1.26505
- 1.08520 2.13363
2 2.6 0.43 126 0.65522 - 2.02642
- 0.69207 - 0.29808
3 2.9 022364 0.38695
- 0.45990
4 3.2 0.08567
Solutio11
We will prepare a table of divided differences similar to Table 5.1.
Tbe coefficients are
Go =0.85467
a, =-0.326 17
a1 ,:e - J.26505
a1 =2.13363 and
a, = - 2.02642
<0> Chapter 5: Interpolation
•
S.J.2 Error bound of Newton's interpolating polynomial
If we have n + I node points, x0 , x,, x2 , •.• , x,, then Newton's interpolating polynomial can be
ex.pressed as
P. (x) = f (x0 )+(x - x0 ) f [x0 , x,]+ (x - x0 ) (x - x,) f [x0 , · · · , x~]
+ •· • + (x - ·r0 } •·• (x - x1t-l ) f [x0 ··· xn ]
1 '
L (x I )--
0, if i *j
•J { I, if i = j
Therefore,
Now, we have to show that H~•• , agrees with f' at each node.
)r •
H;••,(x1 ) = f'(x1 )
Example S.4
Given the following points and the respective first derivatives, determine the approximate value of y
at x = 2.25 using Hcm1ite interpolating polynomial.
X0 = 2.1 X 1 = 2.2 X2 = 2.3
Yo =0.7394 y, = 0.6849 _v2 =0.6359
y~=-0.574 y;=-0.516 y;=-0.4651
Solutio11
In this example, 11 = 2 and, therefore, the Heanite interpolating polynomial will have at most degree 5.
½., (x ) -- ~
(x - x0 }(x - xJ
-~-- - IOO(x- 2.l)(x- 2.3)
(x, - x 0 )(x, - X 1 )
Chapter S: Interpolat ion ~
(x - x 0 )(x - x 1)
Lu(x) ~-~-~ S0(x - 2.l)(x - 2.2)
(-½ - x0 }(x2 - x,)
, ( )- (x - x ) (x - x,)
½_ox - - - ' - - =2 - - -+ - - ' - - = - - - lOOx- 225
(x0 - x1)(x0 - x2 ) (x0 - x 1)(x0 - x2 )
, (X ) = - ~
½.t (x -
- x~
2) (.l" - X0 )
-+-~-~ - 200x+440
(x1 - x 0 )(x, - xi) (x, - x 0 )(x, - x2 )
(x - x,) (x - x )
½~2 (x) 0
----'--=---+ ----'---'--'-- lO0x - 215
(x2 - x 0 )(x2 - x,) (x 2 - x 0 )(x2 - x,)
2
H2.0 (x) ={l - 2(x- x0 )½o (x0 )}{ ½.o (x)}
2
= {1 - 2(x - 2. l)(I00x2. l - 225)}{50 (x - 2.2)(x - 2.3)}
= 75000x 5 - 830000x• +3.67275x 106 x 3 - 8.12285xl0 6 x 2 +8.97897x - 3.968558xl06
H 5 (2.25) = 0.6598 •
<0> Chapter 5: Interpolation
The cubic polynomials and their first and second derivative can be expressed as
S1 (x) = a1 +b1 (x - x1 )+c1 (x - x 1)2 + d1 (x - x1 )3
s/ (x) =b1 +2c1 (x - x1 )+3dJ(x - x1}2 and
s/ (x)=2c1 +6d1 (x - xi)
wlnere a1' b1, c1 and d1 are the coefficients of the jth segment of the cubic spline.
A generalized set of linear equations can be developed based on the above conditions. To develop
the necessary set of equations, we aeed equations from conditions b, d, e and f.
Frnm condition b, we get the following 211 equations.
S2 (xi) =a2 = Y2
b1 +2h,c1 +3h,2d1 - b2 =0
b2 +2h2 c2 +3h_/d2 - b3 =0
c1 +3h1d 1 - c3 =0
<@> Chapter 5: Interpolation
For free boundary. the last two rows of the coefficient matrix have to be modified. The resulting
coefficient matrix is:
a0 b0 Co do a, b, c, d, a, b, c, J, ... ... a.,._2 b... - 2 c.-1 d,._2 a"_' h,.-1 c._, d11_,
I 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0
h' h/ 0 0 0 0 0 0 0 0 ..• 0 0 0 0 0 0 0 0
1 "• • 0 ...
0 0 0 0 I 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 I h/ h/ 0 0 0 0 ... 0 0 0 0 0 0 0 0
0 0 0 0 0 "·0 0 0 0 0 0 .. . 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 h2 1,/ ,.,, ... 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 Ir._, h_,1 h,._, ]
0 I 21,. 31,_' 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
A= 0 0 0 0 0 1 2h, 3/~2 0 -I 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 I 2/,2 3/i,' 0 -] 0 0 0 0 0 0 0 0
... ... ...
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I 2/J,._? 31,,,_?? 0 -1 0 0
0 0 I 3/ro 0 0 -I 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 31,, 0 0 -1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 I 3h, 0 0 -1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I 31,11-? 0 0 -I 0
0 0 I 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 3h._,
Chapter S: Interpolat ion
<0>
The last two rows of B matri x wiU be modified as weU.
Yo
Y,
Y,
Y1
Y2
B= )1,,_,
Y.
0
0
0
0
llo bo Co do b;
a1 l"1 d, a, bi C1 d, ..• a,,,_1 bA- 1 CR- 1 d11-'! "•-I b.-1 C11-1 d,-1
0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0
1 1,. h/ h.,/ 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0
0 0 0 0 I 0 0 0 0 0 0 0 .. . 0 0 0 0 0 0 0 0
0 0 0 0 I h, h/ 1,JJ 0 0 0 0 ... 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 I h2 h,/ ,,., ... 0 0 0 0 0 0 0 0
0 0
0 0
0
0
0 0
0 0
0
0
0
0
0
0
0
0
0
0
0
0
0 0
0 0
0
0
0
0
0
0
0
0
0
0 J
,,__0, 0
h,H!
0
1,11- t
)
0 2\ 3i,/ 0 - J 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
A= 0 0 0 0 0 1 21,, 31,11 0 -I 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 I 2/i, 31,,' 0 -I 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I 2lr.,._2 3/J•-2? 0 -1 0 0
0 0 I 3l1o 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 31,, 0 0 -1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 I 31,, 0 0 -I 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 3h,._2 0 0 -1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2h._1 3/J,,_/
<0> Chapter 5: Interpolation
AG = B
where
ao Yo
ho Y,
Co Y,
do Y-2
a, Y2
b,
G= CI and B = Yn- 1
d, Y.
0
Qn-1
b._, 0
Cn- 1 Yo
d._, Y,, '
Example 5.5
Let us consider four data points, (I, 2), (2, 3), (3, 5) and ( 4, 6). Construct a natural cubic spline that
passes through these points.
Solution
We have four data points. Therefore, we will have 3 subintervals. We define three cubic polynomials,
one for each subinterval in the following manner.
For interval ( 1, 2] ,
2
S0 (x) =a0 +b0 (x - x0 )+c0 (x - x0 ) +d0 (x - x 0 f
3
i.e., S0 (x) = a0 +h0 (x -1)+c0 (x - 1/ +d0 (x -1)
2
i.e., S2 (x)=a1 +b2 (x- 3)+~(x - 3) +d1 (x - 3)'
We will get 6 equations from the fact that the splines S0 (x), S, (x) and S2 (x) must agree with the
nodes at the data points.
Chapter S: Inte rpolation ~
Therefore,
S0 (1)=f(l)i.e.,o0 =2
2
S2' (x) = b2 + 2c2 ( x - 3)+ 3d1 (x - 3)
Reviewing the equations, we find the values for d1e following coefficients.
a0 =2
a, =3
<@> Chapter 5: Interpolation
We still have to determine the values for 8 coefficients utilizing the following equations.
b0 +d0 =l
b, +c, +d, =2
b2+C2+d2=l
b0 +3d0 - b1 =0
b, +2c, +3d, - b2 =0
6d0 - 2c1 =0
2c, +6d, - 2c2 =0
2~+6d2 =0
6.0
5.5
5.0
4.5
S(.t ) 4.0
3.6
3.0
2.5
2.0
1.0 1.3 1.6 1.9 2.2 2.5 2.8 3.1 3.4 3.7 4.0
.t
ExampleS.6
We now consttuct a spline with claimped boundary condition that agrees with the nodes at the same
four data points, (I, 2), (2, 3), (3, 5) and ( 4, 6). The clamped boundary condition is s0' {I)=/ (1) = 2
ands/ (4)= / (4)=3.
For this example, we will be able to use all equations from the previous example up to the point of
the boundary conditions. Due to the clamped boundary condition, our last two equations will be
different from the previous example.
b0 =2
b1 + 2c2 + 3d2 = 3
Reviewing the equations we get the following coefficients right away.
a 0 =2
a, =3
a~=5
b0 =2
For the remaining 8 coefficients we have to solve the following system of 8 linear equations.
a0 +b0 +c0 +d0 = 3; i.e., c0 +d0 = - I
a 1 +b, +c1 +d 1 =5; i.e.. b, +c1 +d, =2
a 2 +b2 +c2 +d2 = 6; i.e., b2 + c2 +d1 = I
b0 +2c0 +3d0 =b,; i.e., 2c0 +3d0 - b1 = - 2
b, + 2c1 +3d, =b2 ; i.e., b, +2c1 + 3d1 - b2 =0
2c0 +6d0 = 2c,; i.e., c0 + 3d0 - c1 = 0
2c, +6d, = 2c2 ; i.e., c, + 3d1 - c2 = 0
b2 +2c2 +3d2 =3
Solving the system of linear equations, we determine the remaining coefficients.
37 22:
Co=- -, do= -
15 I5
22 29 7
b, = - , c1 = - .d, = --
15 15 5
17 34 32
b., = - , c., =- -., d..., = -
- 15 - 15 - 15
The clamped spline is
<0> Chapter 5: Interpolation
,.o
5.5
5.0
,.5
S(.Y) , .o
3.5
3.0
2.6
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 ho h/ h/ 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 ] It, 11I 2 h,3 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 I h2 h,/ 1,/ 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 I 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 I h, h) 1 h3'
A=
0 I 2h0 3h/ 0 -) 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 I 21,, 3h12 0 - 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 I21,2 3/i/ 0 - I 0 0
0 0 I 3'10 0 0 - I 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 J 3h, 0 0 -I 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 3f½ 0 0 -1 0
0 0 I 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 3"3
/r0 =h =h =/,3 =l. Therefore,
1 2
Chapter S: Interpolation ~
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 I 1 I 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 I 1 1 l 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 I 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 I I l
A= ., 0 - I 0 0 0 0 0 0 0 0 0 0
~
0 l 2
0 0 0 0 0 1 2 3 0 - I 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 I 2 .," 0 - ] 0 0
0 0 1 3 0 0 -1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 3 0 0 -1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 3 0 0 -I 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 I 3
Go
bo
Co
do
a,
b,
G= c, and
d,
03
b;
C;
d,
<0> Chapter 5: Interpolation
3
Yo 4
Y, 4
Y, 6
Y2 6
6.5
Yi
6.5
7
B= Y.-, = 0
Y. 0
0 0
0
0 0
0 0
0 0
0
G=A-'B
ao 3
ho 0 .625
Co 0
do 0.375
al 4
b, J.75
CI 1.125
d, -0.875
G= =
a2 6
h2 1.37S
C2 - 1.5
d2 0 .625
a3 6.5
b3 0.25
C3 0.375
d3 -0.125
Chapter S: Interpolat ion ~
x0 ~x ~ x,
3
2.375 + 0.625x+ 0.375{x -1)
0.5 +l.75x+ 1.125(x - 2)2 - 0.875{x - 2)3
S(x)=
1.875+ !.375x- l.5(x - 3)2 +0.625(x - 3)3
5.5+0.25x+0.375{x - 4) 2 - 0.!25(x - 4 )3
7.4~ - - - - - - - - - - - - - - - - -~
6.7
6.0
S(,Y)
2.7
2.0+
1.0
-1.4- -1.8
- -2.2
- ~2.6
- ~3.0- ~
3.4
- -3.8- -4.2
- -4.6
- --<5.0
Example 5.8
Let us consider the five data points (1, 3), (2, 4), (3, 6), (4, 6.5) andl (5, 7) utilized in the previous
example. Construct a cubic spline with clamped boundary that passes through these points and
y0' = 3 and y;= 3.
We have five data points. Therefore, we will have 4 subintervals. Let us utilize the generalized
approach for developing the set of Linear equatioas.
<0> Chapter 5: Interpolation
I 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Iho h/ h0 3 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 h, h2
I
hI l 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 I 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 h1 h/ h/ 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 I 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 I It, ,, 2
3
hl ,
A= 0 I 2110 3ft0 2 0 -] 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 I 2'11 31,12 0 -I 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 I 2/1-,3'1/ 0 - I 0 0
0 0 I 3h0 0 0 -l 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 3ft, 0 0 - I 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 I 311-, 0 0 -] 0
0 I 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 I 2~ 3/J/
I 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 l I 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 I 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 I I I I 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 I 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 1 I ] 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 I 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 l J I
A=
0 1 2 3 0 - I 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 I 2 3 0 -l 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 I 2 3 0 -1 0 0
0 0 l 3 0 0 -] 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 I 3 0 0 -1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 I 3 0 0 -] 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 I 2 3
Chapter S: Interpolat ion
<€P
Yo 3
Y, 4
Y, 4
Y2 6,
Yi 6,
)'3 6.5
)'3 6.5
Y, 1
B= =
0 0
0 0
0
0
0
0
0
0 0
0
Yo'
3
y. ' 3
G = A-'B
Oo 3
ho 3
l'0 4.071
do 2.071
a, 4
b, 1.071
c, 2.143
d, - 1.214
G= =
a2 6
h2 1.7 14
C2 - 1.5
d2 ,0286
03 6.5
b3 ---0.429
C3 ---0.643
d3 1.571
<0> Chapter 5: Interpolation
7.4~ - - - - - - - - - - - - - - - -~
6.7
6.0
5.4
S(.Y)
2.7
2.0+ - - - ~ - ~ - ~ - - ~ - ~ - ~ - --
1.0 1.4 1.8 2.2 2.6 3.0 3.4 3.8 4.2 4.6 5.0
X
Let the second derivatives of the ;piece-wise cubic spline at the given nodes be expressed with
variables M0 , M,, M2 , • •• , M,. such that
s"(x1 )=M1 i=0,1,2, ... , 11
s(x) is defined as:
s0 (x) on (x0 ,x1 )
s, (x) on (x,, ~]
s2 (x) on [x1 , x3 ]
s1 ( x) on ( x,. .x,•.]
S
0
(x) = a0 +b0 x + c0 x 2 +d0 x 3
s, (x) =a,+ b,x +c,x 2 +d,x3
The first aud the second derivative of the ith segment of the cubic spline can be expressed as
s;(x)= b1 +2c1x+3d1x 2
s;(x)=2c1 +6d1x
The second derivative of the cubic spline at the given nodes iu tenns of lhe unknowns M0 , M 1 ,
M2 , ~-- , M" are:
s;(x0 )=M0
s;(x1 )=M,
s;(x,)=M,
s~(x2 )=M2
s;(x2 )=M2
s;(xJ=M 3
s;(x3)=M3
<€,> Chapter 5: Interpolation
· n- 1 )=M n- 1
s•,i- l (r
Therefore.
M 1 - MM x + ~~~~~
'( ) -- ~-~~
S; X
M ,.,x, - M,x,.,
X1 - xl+I X; - xf+l
X;+1 - X 1
(5.25)
(5.26)
-11/M, C _
- xM + x1x 1._, + Dx,., - y 1x;., (5.29)
6
Multiply Equation (5.28) by x1
'
1,,-M;., C D
x I + x1x,., + x I = y1.,xI (5.30)
6
Subtract Equation (5.30) from Equation (5.29)
Om [x,.x,., ]
From the continuity of the first derivative at nodes i = I, 2, . .. , 11 - I, we get 11 - I equations. We have
11+1 unknowns M0 , M 1, M 2 , ••• , M•.
A free boundary case implies thats (x) is linear on (~. x 0 ] and [x,, . oo) .
The equations for i = 1, 2, •· ·, n -1 can be arranged in the following manner.
Y2 - Y1
h,
)'3 - y2
h,
ho+ h, !!L 0 0
3 6
h, h, +h1 h1
0
6 3 6
A= h1 k, +h,, Ii,,
0
6 3 6
Y2 - Y, Y, - Yo
h, ho
)'3 - Y2 Y2 - Y,
h2 h,
B= Y, - yJ J3 - J2
Ii,, h-i
ExampleS.9
Consider 7 data points, (l, 2), (2, 2.6), (3, 5), (4, 6), (5, 5), (6, 8) and (7, 8.2). Construct a natural
ct1bic spline with free boundary thal passes through these points.
There will be 6 segments, and, therefore, will have 6 piece-wise cubic polynomials. We can write
the data as:
2 1
0- 0 0
3 6
l 2 l
- - - 0 0 1.8
6 3 6
- l.4
1 2 1
A= 0 - - 0 B= -2
6 3 6
4
l 2 l
0 0 - - - 2.8
6 3 6
1 2
0 0 0 - -
6 3
M,
M1
Ml = A- 1B
M•
Ms
M, 3.122
M2 - 1.686
M3 = -4.n1
M. 8.794
Ms -6.398
Mo 0
M, 3.122
M2 - 1.686
Ml = -4.777
M. 8.794
Ms -6.398
M6 0
Chapter S: Interpolat ion ~
9.0
8.0
7.0
6.0
S(.Y) 5.0
4.0
3.0
2.0
1.0
1.0
'=- ho M _ ho M + Y, - Yo
Yo 3 o 6 , ho
h,, M + ho M = Y, - Yo ,
3 o 6 , ho .Yo
s' (x) - (xn - •r)? M n-1 +(~. - xn- 1 )2 M n + Yn _ Y,J- 1 (M,. - M,,_,)lr,,_,
2h._, ''•-I 6
2
s'(x,,) (X
n
- x ') M "+ -Vn - yn-1
tJ - .
( M,. - M•-') h,,_,
2h._, "•-I 6
2
s'(x,i)= /r,1- I M V -
"+"''' \I
, n- 1
(M,. - M._,)h,,_,
2h,._, h,,_, 6
( M. - M ,,_, )Ir,,_,
6
ho M + ho M _ Y, - Yo ,
3 o 6 , - ho Yo
Chapter S: Interpolation ~
y,.__, - Yn- 2
"•-2
h h , Y,. - y,J-1
...!ci. M +....!!=LM = y
6 ,1-I 3 " ." h,,_1
ho Ito
0 0 0
3 6
ho l1o +h,
6 3 "·6 0 0
0 !i h, +/t2 ~ 0
A= 6 3 6
0 0
h.-1 It,,_, + h.-1 h._,
0
6 3 6
0 0 0
h
~
h._,
6 3
Y, - Yo
Yo
ho
Y2 - Y1 Y, - Yo
h, ho
y3 - Y2 Y2 - Y,
~ h,
B= Y. - J3 J3 - Y2
h3 lti
"·-• h.-1
Y,. - Y,1- I
.)',,' -
h_,
<0> Chapter 5: Interpolation
Example 5.10
Consider die previous example. However, instead of considering free boundary condition, we will
now consider clamped boundary condition.
Consider y0' = I and y6 ' = J
1 I
- 0 0 0 0 0
3 6
l 2
-6 3
-61 0 0 0 0
--0.4 Mo - 3.183
I 2 1 1.8 M1 3.966
0 - - - 0 0 0
6 3 6 -1.4 M2 - 1.882
l 2 I
A= 0 0 - - 0 0 B = - 2.0 M=A-'B = Ml = -4.840
6 3 6
4.0 M. 9.242
l 2 I
0 0 0 - - 0 - 2.8 Ms - 8.126
6 3 6
I 2 I 0.8 M6 6.463
0 0 0 0 - - -
6 3 6
I l
0 0 0 0 0 - -
6 3
3 3
s(x)=(x,+1 - x) M 1 +(x- x1 ) M1+1
6h,
+ (x,+, - x)y1 +(x- x1)Yi+,
h,
8.0
7.0
6.0
S(.Y} 5.0
4.0
3.0
2,0
1.0
1.0
DI H+-a.RENTIA I
-D tftl AT ON
(6.1)
In Equation (6.1), it is stipulated that the formula works when h approaches to zero. However, an
approximation to Equation (6. 1) is sought in the following manner where his considered to be small.
(6.2)
This approximation, known as forward difference formula, works if It is small. A backward dif-
ference formula can also be used to approximate the first derivative of a function in the following
manner.
(6.3)
Let us utilize the forward difference formula as shown in Equation (6.2) to approximate the first
derivative of .f(x) = e-• at x = 1.5. Table 6. 1 shows the approximate values of the first derivative for
three values of h.
<$> Chapter 6 : Numerical Differentiation and Integration
The exact value of the first derivative off (x) = e-, at x = l.5 is - 0.2231302. ll can be noticed that
the approximation becomes closer to the exact value as h becomes smaller.
We can also derive other approximate formulas for the first derivative utilizing Lagrange interpo-
lating polynomial. Assume that a function goes through three points, (x0 .f (x0 )), (x, .f (x,)) and
(x~.J{x2 )). The function can be approximated in the following manner.
f(x)"" P(x)
+ (x - x0 )(x - x 1 ) f(x,)
(x1 - x0 )(x 2 - x,) -
In order to find the first derivative of j (x), we take the first derivative of its approximate version, P(x).
J'(x)"" P'(x)
p '( X ) -- 2x~
-- - x,-- ~
x2 - f( X 0 )
(x0 - x 1 )(x0 - x 2 )
+ 2X - Xo - X2 f(x1)
(x, - x 0 )(x1 - x 2 )
+ 2x - x0 - x, J(x )
2
(x1 - x 0 )(x2 - x,)
Therefore. the approximation to the first derivative off (x) at x0 can be written as
(6.4)
Equation (6.4) is known as the Three-point formula for the first derivative.
If the three points are again equally spaced but this time with x 0 in the middle so that x, = x0 - hand
x 2 =x0 +h then
(6.5)
Example6.1
Find approximate values of f'(J.5) for f (x) = xe·• using both Three-point formulas with h = 0. L
Solutio11
In order to solve this problem we will need values of J (x) = xe··• at several points. Let us prepare a
table showing the values of the function at x = 1.4, 1.5, 1.6 and 1.7. In practical cases, the values of
the function in the fom1 of data will be available, not the function itself.
<8> Chapter 6: Numerical Differentiation and Integration
X f(x)
1.4 0.3452357
1.5 0.3346952
1.6 0.3230344
1.7 0.3105620
3
f(x +h)- f(x) J'( X ) + -1z (2J( X ) + -/,2 /(ll( X ) + -/1 Jl"l( X ) + ·· · (6.8)
h 2
1 3! 4!
Therefore. each time we use the forward difference formula we introduce an error of O (h ). Since
the step size h is small, we can say that the error of the forward difference approximation of the first
de,rivative is proportional to the step size h.
Let us derive another approximation formula for the first derivative by tal<ing Taylor's series expan-
sion of f(x+2h) about x.
4
f(x+2h)=J(x) +2hf'(x)+ I? Jt21 (x)+ g1,J J(l► (x)+ 16"' f'l(x)+ ···
2 3! 4!
I (x+ 2h)- I (x) f'( X ) + -2h 1111 ( X ) + -4/i2 Jn3>( X ) + -8/i3 Jc•> (X ) +··· (6.9)
2h 2 3! 4!
3
- f(x +2h)+4f(.x+h) - 3f(x) f(x) - 21i2 Jf3l(x)- 611 j<•l (x) -· ··
21! 3! 4!
Equation (6. IO) is lhe first Three-point formula and the error introduced by this approximation of the
first derivative is 0(112 ) which is proportional to the square of the step size h.
lo order to derive the second Three-point formula, take Taylor's series expansion off (x - h)
about x.
, 3
, J,- (2) /r (3)
f(x - h)=f(x) - 1,f (x)+ - f (x) - - f (x)+ ··· (6.11)
2 3!
2h 3 < 21,6
f (x+h) - f(x - '1) =2hf'(x)+- f 31(x)+ - J<•i (x) + ··· (6.12)
3! 6!
Divide Equation (6. 12) by 2h.
(6.13)
2 5
f'(x)= f (x+h) - J(x - h) h / l l (x) - h / 6l (x) - ...
2/, 3! 6!
2 5
where0 ( h 2) = -h-j •(ll (x) -h-f !6} (x) - ···
31 6!
Equation (6. 15) is the second Three-point formula and the error introduced by this approximation of
the first derivative is also 0(li2) which is proportional to the square of the step size h. This time the
dominant error term is, however, half of that for the first Three-point formula.
Chapter 6: Numerical Differentiation and Integration ~
h1 J,3
>(x) - -f 31 (x)+ ·· ·
1
f (x - h)= f (x) - hf'(x)+- f
2 3!
Add these two expressions.
2 4
f(x +h)+ f(x - h)=2J(x)+-2h J <'-> (x)+ -2h J <•l (x)+···
2 4!
2/i2 <'> 21, • <•)
f( x+h) - 2/(x)+ f(x - h)=- f - (x) +- f (x)+···
2 4!
f(x+h) - 2/(x)+ J(x - h) ,11 2h 2 !(') \
h2 1 (x)+4! (xi' +···
(6. 17)
Example6.2
Find an approximate value of /<2\ 1.5) for f (x) = x[' with h =0.1.
Solutio11
In order to solve this problem we will utilize Table 6.2 prepared for Example 6.1 .
Using the formula g iven by Equation (6.17)
2
2. Find the approximate values of /'(2.1) and / >( 2.2) given that
f (2.0) = 4.6897983
f (2.1) = 4.6915701
f (2.2) = 4.6698 I92
f (2.3) = 4.6255909
3. Find the approximate values of f'(-2.6) and J'11(- 2.6) given that
The general form of 11umerical integration off (x) over [a, b] is a weighted sum of the function
values at a finite number of sample points, known as quadrature, andl is:
b N
J f(x)dx =I, w.f(x,) (6. 18)
" k=-0
y
/(b)
/(a) ------------
a b X
Figure 6. 1 Trapezoidal Rule
We would, therefore, calculate the area of the trapezoid whose venices are (a, 0), (b, 0), ( b, f(b) )
and ( a, /(a)). The length of the two parallel sides are /(a) and J(b). The height (perpendicular
distance between the two parallel sides) trapezoid is (b - a).
b b- a
J" f(x)dx., - 2
[f(a)+ / (b)]
b h
J" f(x)dx., - [f(a)+ f(b)]
2
(6.19)
<$> Chapter 6: Numerical Differentiation and Integration
whcrch=b - a
It js obvious from Figure 6.1 that if f ( x) is linear then die Trapezoidal rule would produce no error.
However, for f ( x) second degree or higher there wi U be error produced by the Trapezoidal rule.
Example6.3
Find the approximate value of r x ~dx using Trapezoidal rule and calculate the absolute error.
Sallltio11
Using Equation (6.18)
b h
J• f(x)dx .. -2 [f(a)+ /(b)]
, 2- 1
J- f(x) "' - 2 [f(I)+ f(2)]
I
(6.20)
Example6.4
Find the approximate value of J,2 x 4 dx using Simpson's rule and calculate the absolute error.
Solutio11
Using Equation (6.20)
• l
J- f(x) dx "' -6 [/(1)+4/(l.5)+ /(2)]
I
where
and~ is an unknown quantity between the minimum and the maximum of x0 and x, .
The linear Lagrange interpolating polynomial can be used to derive the Trapezoidal rule.
J: f(x)dx"' J: P, (x)dx
b
J• f(x)dx,,, _h
J 1•{- (x - b)f(a)+(x - a)f(b)}dx
•
f• f(x)dx"' -hl[
b (x - b)2 f(a)+ -'-----'-
-'------'-
2
2
(x - a) f(b)
2
I
, . f(x)fil' "' -h {/(a)+ J(b )}. the formula for Trapezoidal rule with the truncation error
f• 2
Using the fact that (x - x0 )(x - x,) is always positive in [a, b], we can use the Weighted Mean Value
Theorem of integration.
~(x) indicates that it depends on ..rand by applying the Weighted Mean Value Theorem it can be
replaced by 17 s uch that 17 is in (a, b).
J,3
The error term of the Trapezoidal rule, therefore, is - -/"(T/). The error term indicates that the
12
Trapezoidal rule provides accurate results for linear functions.
where
s
and (x) is an unknown quantity between the minimum and the maximum of x 0 • x, and x 2 that
depends on x.
The truncation error is (x - xo)(x - x,)(x - x 2 ) /(3) ( ; (x)).
3!
Therefore, the error of Simpson's rule is
We cannot apply the Weighted Mean Value Theorem to the error term directly since
(x - x0 )(x - x 1)(x - xi) changes sign in (x0 ,x2 ).
Expand / about x 1 using Taylor's polynomial of third degree.
2
(x - r) (x - x) 3
J(x)=f(xi)+ (x - x,)/'l(x,)+ ~ , /(2l(x,)+ 6, j<J>(x,)
+ (x - x,)' J'·1(s(x))
24
f~..,, J(x)dx= f'' [f(x,)+(x- x,)/ 11 (x,)+ (x - x,}1 f 21 (x,)+ (x - x1,}3 / 3>(x,)]dx
,. 2 6
Jx.''J( ·)d
X X -
1
(x - x,}2 jA•l(,}
- [ X /( X } +-'----'-'-
2
(x - x,}3 JA1l( X 1 }+-'----'-'-
· ,l 1 +-'----'-'-
6
{x- x,}4 JAll( X 1
24
)I'
'•
+ f'[(x - x,)' /•>(s(x))]d.x
'• 24
Since (x - x,)' in the last term is always positive. we can apply the Weighted Mean Value Theorem
of Integral to the last tem1.
Chapter 6: Numerical Differentiation and Integration ~
Since we are looking for the absolute maximum error, we choose a common number between .;1 and
<;2 that will give the absolute maximum of / 41 (x) in (x0 ,x1 ).
The error term inclicales that Simpson's rule provides accurate results for functions of third degree
or lower.
C.
J'.s - ?2x
I
-
[ - 3
d d. t e 2 ' s.in{3x )dx
/( I.8)=3.12014
f (2.0) = 4.42569
f (2.2) = 6.04241
/(2.4) =8.03014
f (2.6) = I0.46675
b- a
wlaereh= - - andx,=a +klt fork=0, I, 2, ... ,11
n
Example6.S
b - a 1t
h= - - =-
n 20
Im
x,=a+kh= , k=0, I, 2, ....., 20
20
k=I
-1 ]
= .2:..[sin(
40
1
0)+ 2I,sin(/m) + sin(n)]
t=I 20 •
= J.995886
b- a
whereh= - - andx,=a +kh fork=0, I, 2, ... ,n
n
Chapter 6: Numerical Differentiation and Integration ~
Example6.6
Find Jo" sin (r)dx by dividing the interval into 20 subintervals.
b- a 1t
n.=20 h= - - = -
11 20
r2 2x
c. Joe cos(3x )dx, 11 =&
f J(x) dx
I "
J f(x)dt = L, w, f(x,)
-I l=I
where
w1 is d1e ith weight and x1 is the ith node.
<0> Chapter 6: Numerical Differentiation and Integration
With 11 = l, we have two wilcnowns, 1111 and x 1 that can be determined by restricting the integration to
be exact for two functions,
For f (x) = I, The exact integration is 2 which forces the weight iv, to be 2. For f (x) = x the exact
integration is
J, xdx=O
-I
w,x,=0 (6.21)
To satisfy Equation (6.2 1), x, should be 0, because 1111 is already determined to be 2. Hence for
f(x)= l wehave
(6.23)
There are four unknowns x,, x 2 , w, and 1112 in Equation (6.23). To determine the unknowns, we
require Equation (6.23) to be exact for the following four monomials,
Therefore,
w, +w2 =2
W 1X 1 + W 2X 2 = 0
(6.24)
will give exact values for all polynomials of degree equal or less tham 3.
Now, consider the case of n = 3.
(6.25)
There are six unknowns x 1• x 2 , x 3 , w" w 2 and w 3 in Equation (6.25). To determine the unknowns, we
require Equation (6.25) to be exact for the following six monomials,
2 3 45
/)(.x =J ~x,x , .t , x ,x.
Therefore,
+ W~ + IV3 = 2
1111
IV1X 1 + w 2 x 2 + w3 x 3 =0
W1Xf =t
+ W1Xi +w~x:
(6.26)
w x;+ w x;+ w xJ= 0
1 2 3
-I 4 4 _ 2
wlxl + IV1 X2 + W y-X3 -,
IVIXI
5
+ W 2X 15 + W 3 X35 = 0
The unknowns are already available for most commonly used value of n. Table 6.3 shows d1e nodes
and weights for 11 = 2, 3, · · ·, 8.
The nodes can also be determined using Legendre polynomials as they are the zeroes of the Legendre
polynomials on tbe interval [- 1, I] . Legendre polynomials are defined as:
P0 (x)=l
II x, w,
2 ± 0.577350269 1896257 1.0
3 ± 0.77459666924 14834 0.5555555555555556
0.0 0.8888888888888888
4 ± 0.86113631 I 5940526 0.3478548451374538
± 0.3399810435848563 0.6521451548625461
5 ± 0. 9061798459386640 0.236926885056189]
± 0.5384693101056831 0.4786286704993665
0.0 0.5688888888888889
6 ± 0.9324695142031521 0.1713244923791704
± 0.6612093864662645 0.3607615730481386
± 0.2386191860831969 0.4679139345726910
7 ± 0.9491079123427585 0.129484966 I 688697
± 0.7415311855993945 0.2797053914892766
± 0.405845 1513773972 0.38) 830050505 ll 89
0.0 0.4 l.79591816734694
8 ± 0.9602898564975363 0. 1012285362903763
± 0.7966664774136267 0.22238 10344533745
± 0.5255324099 163290 0.3137066458778873
± 0.1834346424956498 0.362683783'3783620
For example,
P, (x)=x
Pi (x)=½{3x 2 - 1)
~(x)=½{5x 3 - 3_t)
P. (x)=½(35x• - 30x 2 +3)
P; (x) = t(63x 5 - 70x 3 + 15x)
In most cases integrations would be sought over [a, b) instead of [- 1. 1). In such cases, we can covert
the integration by substituting a new variable and then apply the formula for Gaussian integration.
Chapter 6: Numerical Differentiation and Integration ~
I= f f(x)dx
-(b-a) (b+a)
X- - - I+ - -
2 2
I= (-b-a)f'
- _,f(r)dr
2
Example6.7
Determine the following integral using Gaussian integration formula.
Solutio11
The function we are integrating is
f(x)=l+2x - 1.7x2
I= f,J(t}d1
I= w,f (1,) + w 2 f (1 2)
The function used in Example 6.7 is a straightforward one that could be integrated using the stand-
ard integration rule instead of Gaussian integration rule. It would be worthwhile to examine the use
of Gaussian integration rule to integrate more complex functions. We consider the following four
integrals.
11 =
f2vxrI dx, f ,- = J2 -1+x
1 1
·I - dx,1 = i2
3 -I- dxand f ,= J2e-' dx
1+x
1 1
1
Io all four cases, the variable x has to be replaced in order to apply Gaussian integration rule. Also,
none of the four functions are polynomial, therefore, we expect some error. In all four cases, a= I
and b=2.
First we use 11 = 2
J'
I,= -2I _, f(t)dt
J'i
where/(1)= ,.--:--;;
vt + 3
The exact value of / 1 is 0.828427 1247 producing a relative absolute error of 0.03%.
? I
- J
I,= - - dx
' I +x
r+3
x= - -
2
where/(t)=--2_
t+5
Chapter 6: Numerical Differentiation and Integration ~
r+3
x= -
2
4
13 = -If 1 f(t) dt where/ (1)
2 -1 4+(r+3)1
The exact value of/3 is 0.3217505544 producing a relative absolute error of 0.01 I%.
r+3
x= -
2
,.3
14 =.!.f
2
I
-I
f(r)dt whcrc/(r)=e 2
The exact value of/4 is 0.2325441579 producing a relative absolute error of 0.022%.
Let us now use 11 = 3.
11 = -I
2
f I
f(t)dr
✓2
where/(1)= r:-;-;,
- 1 ,JI +3
/ 1
j
0.5555555556/ (0.7745966692)
=½ +0.5555555556! (--0.7745966692)
l
+0.8888888889 f (0)
/
1
=0.8284202635
The exact value of / 1 is 0.828427 1247 producing a relative absolute error of 0.00083%.
2 l
l, = -
- ' l+x f
dx
1+3
x= -
2
/ 2 = -If'_,f(t)dr where/(1)= - 2
2 1+5
l
l
11 = {wJ (x, )+ w 2.f (x1 )+ w 3/ (x,)}
2
0.555555SS56f (0.7745966692)
11
j
=½+0.5555555556/(--0.7745966692)
+0.8888888889J (0)
/2 = 0.4054644809
2 I
13 = 1~l+x- x
l
1+3
~t= -
2
4
1. = ..!..J ' f( r)dr where/(1)
, 2 _, 4+(t+3}2
l
I
/3 =
2{wJ(x,)+ w1 f (x2 )+ w3J(.,J}
0.5555555556! (0.7745966692)
l3 = ½+0.5555555556/ (--0.7745966692)
! +0.8888888889 f (0)
13 = 0.3217559457
Chapter 6: Numerical Differentiation and Integration ~
r+3
x= -
2
,.3
1. =..!.f' f(r)dr where f(r)=e-1
2 -I
l
I
I. =
2{wJ (x, )+ 1V2f (Xi) + w3 f (x3 )}
!
0.5555555556/ (0.7745966692)
1. =½ +0.5555555556/ (-0.7745966692)
+0.8888888889/ (0)
1. = 0.2325440464
The exact value of/4 is 0.2325441579 producing a relative absolute error of 0.00005%.
l.5
b.
f
1
x 2 Ln(x)dx
c. f
I
15
_l:!_dx
X2 - 3
INITil1 L-VAt R
-- ---- D- ~LJlY DIH AL
- . - - - - - - + - - - - - + ~ - - - . - - - - - - - + - - - I - - -~ ~ rfB
Variables in many engineering problems are related in the fom1 of differential equations. Properties
of materials, dynamic behavior of devices and current and fluid flow can be described by differential
equations. In many applications, general solutions of differential equations are sought to understand
lhe overall characteristics of a device or a process. But in a vast majority of cases number specific
solutions are desired for design and stability purposes. In this chapter, we will introduce several
nwnerical techniques to solve first-order differential equations. We will specifically consider the
equations whose initial values are given and as such they are also called initial value problems.
Most differential equations applicable to engineering problems have unique solutions. We can start
with a generalized solution for such a problem and force that 10 satisfy the given initial condition.
However, it is still worthwhile to address the basics related to the solution of differential equations.
Botil the left hand and the right hand side are explici t functions of the independent variable, x.
Therefore, we can integrate both sides with the following result.
y(x) = f r(x)dx+c
wlhere c is an arbitrary constant of integration and f r(x) dx is any fixed antiderivative of r.
A particular solution for the above differential equation can be obtained by detemiining c for a
specific value of y(x) at some given point, y(x0 ) = y0 •
<0> Chapter 7: Initial-Value Problems for Ordinary Differential Equations
where the right hand side is a function of both the independent and dependent variables, we just can-
not integrate both sides to obtain a solution. In Lb.is case, we have to solve the differential equation
using numerical techniques.
Regardless of the right hand side, it is sometimes more efficient to solve a differential equation with
an initial value using numerical techniques.
Before we proceed, we would like to address what makes an ordinary differcmial equation solvable
and is the solution s table? An ordinary differential equation is well-posed if it has a unique solution
and small changes to the equation only imply small changes to the solution.
Definition 7.1
A function/ (x,y) is said to satisfy a Lipschitz condition in the variable yon a set D c R 2 if a con-
stant K >0 exists with If (x, y, )- f (x, y )I~K IY,- y
2 2
1 whenever (x, y,) and (x, y2 ) are in D . The
constant K is called a Lipschitz constant for/. •
The relationship II (x , y
1) - f ( x, y 2 )I~KIy, - _v Ican be viewed as.
2
Theorem 7.3
Let D = { (x, y)la:,; x:,; b and - 00 < y < 00}. If/ is continuous and satisfies a Lipschitz condition on
D in the variable y, then the initial value problem
is well posed.
Chapter 7: Initial-Value Problems for Ordinary Differential Equations ~
y
y(xo)
y(xo+h)
Yi
X
Figure 7. 1 Forward Euler's method
The process is repeated by estimating the slope at x = x, and extending the slope line to x = Xr The
slope line will intersect with the vertical line, y = x 2 at ( x 2 , y2 ). y2 is, tiberefore, an approximate value
of the function y at x = x r
Slope at (x0 , Yo) is y'(x0 ). The slope can be written as
(7.1)
The slope y' is usually expressed as an implicit function of x and y i.e., y' = f(x,y). Therefore,
Equation (7.1) can be written as
(7.2)
<0> Chapter 7: Initial-Value Problems for Ordinary Differential Equations
Considering Y,, is an approximation toy( x.). Equation (7.2) can be written in the form of a sequence
equation in the following manner.
wlnereh=x••,- x.
The sequence shown in Equation (7.3) is the implementation of Forward Euler's method. We will
ex.amine the implementation of Backward Euler's method later.
Example 7.1
Consider the initial value problem y' =2+ y - 2x, 0~x~I . y(0)=l. Solve for y using Forward
Euler's method. Use a step size of 0.1.
Solution
y' =f(x, y) =2+ y - 2x and h=0.1
y(x) =2x+e'. The results with h = 0.1 and corresponding errors are s hown in Tables 7.1 and 7.2.
The IVP is also solved with h = 0.05. Table 7.2 shows the results and the absolute errors.
Compare the absolute error columns in Tables 7.l and 7.2. It can be noticed that the en·ors are
reduced when the step s ize is reduced to half. However, we needed twice as many steps as we needed
when the step size was 0. I. ■
Chapter 7: Initial-Value Problems for Ordinary Differential Equations ~
where x. ~t ~x. +h
Y,,..1 is approximated using Forward Euler's method as y,,..1 "'Y(x,.)+hY'(x,,). This is a truncated
version of the Taylor's series shawm in Equation (7.4). Therefore, at every step of Euler's method, a
local truncation error is introduced as
A local truncation error is defined as the error in the presem step if tbere were no error in the previ-
ous step.
In Forward Euler's method we compute y,,..1 as
Y'(x.) = f (x., Y ( x. ))
The combined error which is the global truncation error at step n + l lbecomes
As the process moves to the next step, the previous error is added to the current error. For Forward
Euler's method. the local truncation error is O ( h2 ). The method is referred as a first order technique.
A method with a truncation order of O ( ht+t } is called kth order. In general, for the same step size, a
method with higher order local truncation error provides lower local tnmcation error.
A numerical method for solving initial value problem is stable if a small perturbation in lhe initial
vaJue results in a small change in the solution.
A numerical method is convergent if the nwnerica!Jy computed solution approaches to the exact
so lution as the step size approaches to zero. A model problem shown. in (7.5) is often utilized to test
the convergence of a numerical method.
The exact solution of (7.5) is Y = exp (- ax) that satisfies the condition Y (0) = l and decays smoothly
to zero at x =oo. If the numerical method is stable then its solution should satisfy y(x.) ➔ 0 as
x. ➔ oo for any choice of the step size h.
The solution of the model proble m utilizing Forward Euler's method is
Y,,., =Y. +lt(- ay"), 11<::0, Yo =l
By induction
•+I
y_.1 =1
( - ah ) Yo (7.6)
Equation (7.6) implies that for the stability of Forward Euler's method,
The stability condition, therefore, implies that the step s.ize should be smaller than 2/a.
<0> Chapter 7: Initial-Value Problems for Ordinary Differential Equations
The Forward Euler's method is an explicit method since we compute y,,.1 based on die known com-
ponents y,, and f(x,,,y,,). Explicit methods are easy to implemem, they. however, have the limita-
tions on step size to maintain numerical stability. Euler's mediod converges widi order l. In general,
a numerical mediod is convergent with order p if it satisfies the following.
where k is a constant.
From die results shown in Tables 7. I and 7 .2 a general trend can be observed that in a first order
technique when the step size is halved the error is hal ved.
(7.7)
(7.8)
Equation (7.8) is the required sequence expression for Backward Euler's method. Equation (7.8) dic-
tates that at each step of Backward Euler's method, a nonlinear algebraic equation has to be solved.
Let us apply the Backward Euler's sequence to the model problem shown in (7 .5).
Y• = (l )',,_,
+ah)'
n>0
- '
" =I
JO
By induction
Yn- l
Y. = l
(1 +a I,)
y = Yo (7.9)
" (l +ah)"
Equation (7.9) satisfies that y(x,,) ~ 0 as x. ➔ oo for any choice of the step size h. Hence, Bacl..-ward
Euler's method is convergent and stable for au h > 0.
Chapter 7: Initial-Value Problems for Ordinary Differential Equations ~
Like Forward Euler's method, Backward Euler's method also has first order convergence property
making both methods unsuitable for many applications.
Example 7.2
Consider the initial value problem y' = 2+ y - 2x , 0 5 x 51, y (O) = 1. Solve for y using Bacl-.-ward
Euler's method with a step size of 0.J.
Solutio11
Tabl e 7 .3 The results of the IVP using Backward Euler's method with h = 0.1
In order to solve Equation (7. 10), we can integrate both sides of the equation from x. to x..,.,.
Y(x..,)- Y(x,.)= r•··•
"•
f(x, Y(x))dx (7. ll )
Utilizing Trapezoidal rule to approximate the integration, we can evaluate the right hand side as
Example 7.3
Consider the initial value problem y' = 2+ y - 2x, 0 ::;x::; I, y(0) = l. Determine y using modified
Euler's method with a step size of 0.1. Compare the results with exact solution y(x) = 2x +e".
Solutio11
y' ;;; J( x, y) aa 2+ y - 2x and It ;;; 0. 1
x, =x0 +h=0+0. l= 0. I
Table 7 .4 The results of the example IVP using modified Euler's method with h = 0.1
•
<@> Chapter 7: Initial-Value Problems for Ordinary Differential Equations
y(x+h)= y(x)+hy'(x)+ R,
1 1
y(x+h)= y(x)+ hy'(x)+ ~ y'(x)+ ~; y• (x)+ R3
Example 7.4
Consider the initial value problem y' =2+ y - 2x, 0 ~ x ~ l, y(O) =l. Determine y using Taylor's
method of ordertwo wi th a step siz,e of 0.1. Compare the results with exact solution y(.x) = 2x+e' .
Solutio11
y'=2+ y - 2x
, t,2 I
The sequence (7. 14) can be used to estimate y in a successive manner. The results with /, = 0.1 are
shown in Table 7.5.
Chapter 7: Initial-Value Problems for Ordinary Differential Equations ~
I
I
I
I
I
I
I
I
I
I
__________ ..,--=:;;,,_ __, _.
dv_________
I
~
•
y (x. ) I
dx I
I
I
I
I
I
I
I
x,,
Figure 7 .2 y as a function of x
<€,> Chapter 7: Initial-Value Problems for Ordinary Differential Equations
(7.17)
or, alternatively
f,.
.t,,+li
y(x. +h)- y(x.) -= y'(x)dx (7.18)
f x,+h
y'(x)dx""
f x,+h
P(x)dx (7.19)
x. ..r..
where P(x) is an approximation to the actual function, y' (x). This approximation is necessary
because y' (x) is a fw1ction of x and y and is unknown until we could calculate the value of y. As
mentioned before, in an IVP, y'(x)js usuaJJy given in the form of y'(x) = f (x,y).
P(.x) can be generated by utiJizing Lagrange Ime1polaring Poly110111ia/. Assume that the onJy infor-
mation we have about a function, g(x) is dlat it goes through three· points: (x0 ,g(x0 )),(x,,g(x,))
and ( x2 , g (x2 ) ). The mathematical expression for g (.x) is unknown to us. However, an approximation
to g ( x) can be generated as:
P(x) ""g(x)
P( X ) -- -(x-- ~
x,)(x
-~ - x ~g
1) ( . )
,t 0
(Xo - x, )(Xo - X2)
(x - x 0 )(x - x,) ( )
+ - g x,
(x, - x0 )(.x, - ,\'..i)
(X - ,t )(.K - .-\'
0 1 ) ( )
+---"---'-- g x,
(X2 - Xo}(.~2 - x,) -
If we need to differentiate or integrate the function, g (x) which is unknown. we can _perform differ-
entiation or integration on P(x) instead.
Using Simpson's integration rule,
(7.20)
We can apply Simpson's Integration to Equation (7.19) with the following substitutions:
x0 =x.; x 2 =x. +hand therefore, h' =I,/ 2 and the midpoint, x 1 =x,. +% and g(x,.) = y'(x,.).
(7.21)
Compared to Euler's Fonuula, an average of six slopes is used in Equation (7.21) instead of just
one slope. Actually, the slope at the midpoint has a weight of 4. The slope at the midpoint can be
estimated in two ways.
y(x. +I,)- y(x,.) "'~[y'(x. )+ 2y'(x. +1) +2y'( x. + ~)+ y'(x,. + h)]
+
y(x. h) "'y(x. }+~[ y'(x. )+ 2y'(x. +%) +2y'( x. + %
)+y'(x. +h)]
+ +i)+2y'( +i)+ y'(x.+,)]
y( x.+,)"' y(x,, )+ i[y'(x.) 2y'( x. .t ,,
(7 .22)
'( h)
·2 - "2"2
( h h)
y X +- ;k_,; f X + - ,)' +- k1
<$> Chapter 7: Initial-Value Problems for Ordinary Differential Equations
Substituting the slopes into Equation (7.22) gives us the formula for Runge-Kutta Method of Fourth
Order:
(7.23)
Example 7.S
Consider the initial value problem y' = 2 + y- 2x, 0 $ x $ I, y(O) = l. Solve for y using Runge-Kutta
method of order four with a step size of 0.1. Compare the results with exact solution y(x) = 2x+e'.
Solution
.v'= f(x,y) =2+ y - 2x and h=0. l
Xo =0, Yo = I
k, = /(x0 ,y0 ) =2+ Yo - 2x0 = 3.00000000
It
Y, = Y, + (k, + 2k2 + 2k3 + k4 ] = 1.62140257
6
and soon.
Table 7.6 shows the results obtained using Rw1ge-Kutta method of order four with h = 0.1.
Chapter 7: Initial-Value Problems for Ordinary Differential Equations ~
Solution
Ta ble 7.7 shows the absolute error of Euler's, Modified Euler's, Taylor's method of order two and
Range-Kutta method of fourth order.
Absolute E rror
Modified Taylor's Runge-Kutta
11 t Euler's Euler's Order two Fourth order
0 0.0000 -4.0 -4.0 -4.0 -4.0
l 0.0025 0.11796812 0.00997687 0.01015688 0.00003196
2 0.0050 0.18006938 0.01554058 0.0158214 0.00004970
3 0.0075 0.20616661 0.018 15522 0.01848379 0.00005797
4 0.0100 0.20983898 0.01885312 0.01919484 0.0000601 1
(Co111inued)
<@> Chapter 7: Initial-Value Problems for Ordinary Differential Equations
Absolute Error
Modified Taylor's Runge-Kutta
n I Euler's Euler's Order two Fourth order
5 0.0125 0.20024752 0.0.1835424 0.01868743 0.00005842
6 0.0150 0.18346835 0.01715381 0.01746569 0.00005452
7 0.0175 0.16344154 0.01558657 0.01587039 0.00004946
8 0.0200 0.14264302 0.01387349 0.0141265 0.00004395
9 0.0225 0.12255773 0.01215574 0.01237777 0.00003845
10 0.0250 0.10401055 0.01051918 0.01071162 0.00003322
11 0.0275 0.08739581 0.00901193 0.00917705 0.00002842
l2 0.0300 0.07283515 0.00765684 0.00779735 0.00002410
13 0.0325 0.06028456 0.00646034 0.00657907 0.00002031
14 0.0350 0.04960607 0.00541855 0.00551829 0.00001700
15 0.0375 0.04061468 0.00452158 0.00460493 0.00001417
16 0.0400 0.03310836 0.00375632 0.00382567 0.00001175
J7 0.0425 0.02688643 0.00310838 0.00316586 0.00000971
18 0.0450 0.02176025 0.00256331 0.00261079 0.00000799
19 0.0475 0.0175587 0.0021073 0.00214639 0.00000656
20 0.0500 0.01413047 0.00172761 0.00175971 0.00000537
It can be noticed from Table 7.6 that the errors produced by the Euler's melhod are the highest, errors
by the Modified Euler's method and the Taylor's method of order two are comparable and the errors
produced by the Runge-Kutta method of order four are the lowest. It is also interesting to note that
the Runge-Kutta method achieves this degree of high accuracy without having to compute higher
order derivatives of y . Runge-Kutta method of order four is also known as classic Runge-Kutta
method. There are also several variations of Runge-Kutta method :available in literature, such as
Larson·s fifth-order Runge-Kuna method, Butcher's sixth-order Runge-Kutta method and Runge-
Kutta-Fehlbcrg method.
Compute the absolute errors in each case if tbc exact solutiorn is y = x - Sexp(- x).
The second approximation technique can be derived from an (n + l) order Taylor method. The cor-
responding initial condition and the difference equation can be wrinen as
illo = Yo
Since the local truncation error T,., (h) is O (Ii"), a constant C independent of the step size h exists
such that T,., (h) "'Ch".
The local truncation error produced by the same 11th order method. with a step size of sh can be
approximated as
Select s such that the local truncation error is bounded by the given tolerance, ,:;.
(7.24)
Runge-Kutta-Fehlberg method estimates the local truncation error ofRunge-Kutta method of order
four by utilizing Runge-Kuna method of order five.
First. we find an approximation to the solution using Runge-Kutta method of order four in the fol-
lowing manner.
(7.25)
Then we seek a better approximation to the solution using Runge-Kutta method of order five in the
following manner.
Chapter 7: Initial-Value Problems for Ordinary Differential Equations ~
We assume that ro1 ""w1 when a fixed step size h is used. Therefore,
At each step, both Equations (7 .25) and (7 .26) require the evaluatioru of foUowing coefficients.
k, =hf(x1 , (J)1 )
Note that both Runge-Kutta methods as utilized in Runge-Kutta-Fehlberg method use the same
six coefficients. This amounts to a computational savings since a stand-alone Runge-Kutta method
of order four would require four coefficients and a stand-alone Runge-Kutta method of order five
would require six coefficients to be computed.
If (l/h)l@ - w,.,I
,+1 >t:. then reject the injtial choice of step size hat the ith step. Calculate a new
step sjze sh and repeat the step. If (1/h)l<O,+, - w,+,l~t:. then accept the computed value at the ilb
step with step size I, and calculate a new step size sh to be used io the next step. In most of the
applications of Runge-Kutta-Fehlberg method, Runge-Kutta method of order four is utilized to
compute the solution giving us 11 =4 to determine the reduction or inflation factor of the step size
in Equation (7 .24).
Since we are mainly interested in controlling the error which calls for reductions in step size,
a min imum limit on the step size could be placed to avoid computations in the zones where the
error is acceptable. Moreover, the step size inflation part could be completely omitted. There
are, however, more than one ways to implement the error control and step size changes using
Runge-Kutta-Fehlberg method. A conservative version of the step size reduc tion (inflation) fac-
tor as shown in Equation (7 .27) is utilized in many implementations of Runge-Kutta-Fehlberg
method.
(7.27)
<0> Chapter 7: Initial-Value Problems for Ordinary Differential Equations
Example 7.7
Consider the initial value problem y' = 2+ y - 2x, 0:,; x::;; I, y(O) = I. Use Runge-Kuna-FeWberg
method to approximate the solution with a tolerance e = !0-6 and a maximum step size of 0.2.
Compare the results with the exact solution y (x) = 2x + e'.
Solutio11
First we use the maximum step size of 0.2 to calculate 1he six coefficients.
The local error is greater than the tolerance, therefore, the step size is reduced by a factorof0.7157 !07
and the computalion is repeated. The results are shown in Table 7 .8.
Chapter 7: Initial-Value Problems for Ordinary Differential Equations ~
Absolute
11 X Step size Y. Exact Solution Error
•
0 0.000000 1.00000000 1.00000000
I 0.168750 0.168750 1.52132430 1.52132415 0.00000014
2 0.328931 0.160181 2.04734315 2.04734286 0.00000030
3 0.480977 0.152046 2.57960913 2.57960866 0.00000047
4 0.627272 0. 146294 3.12703859 3.12703793 0.00000066
5 0.768032 0.140760 3.69158332 3.69158245 0.00000087
6 0.905314 0.137283 4.28333890 4.28333779 0.00000111
7 1.000000 0.094686 4.71828307 4.71828183 0.00000124
•
Problem Set 7.2
1. Use Runge-Kutta-Fehlberg method of order four 10 solve the following initial-value
problems. Use a tolerance of 10-6 aad a maximum s1ep size of 0.2 aad a miaimum s1ep
size of 0.0 I .
a. y' =xe 2' - 2y, 0::;x::; 1, y(0)=0
2
b. y'=l+(x - y) , 1:,;x::;2, _v(l)=l
2. Solve the followiag iaitial-value problem using Runge-Kutta-FehJberg method of order four.
Use a toleraace of 10-6 and a maximum step size of0.2 and a rninimun1 step size of0.01.
,.(x 1
)=<f>(x )+ f.
3
(551i•)_f._,(591,•)+l- (37/z•) _f._(91i•)
2 3
3
'i' "' " 611 4 21,3 12 21,3 12 6h 4
</>(x..,) = </>(x. )+ ;
4
{5Sf. - 59f.,. + 37/..
1 2 - 9/,,. 3 ) (7.28)
Chapter 7: Initial-Value Problems for Ordinary Differential Equations ~
Equation (7.27) is known as 4'h order Adams-Basbfortb fonnula. We need f.,, f.,_,, J•.1 and f._3 to
calculate the approximate value al x.+i· At the beginning tbey are calculated using Runge-Kutta
method of order four.
Example 7.8
Consider tbe initial value problem y' =2+ y - 2x, 0 ~x ~ I, y(0) =I.Use 4m order Adams-Bashfortb
method to approximate the solution with a step size of 0.1. Compare the results witb the exact solu-
tion y(x)=2x+e·'.
Sollltio11
Let f(x.y)=2+ y - 2x
The first four approximations can !be obtained from Rungc-Kutta method of order four shown in
Example 7.5.
Yo =I, y, =l.30517083, y2 =l.62140257, y3 =l.94985850
•
<$> Chapter 7: Initial-Value Problems for Ordinary Differential Equations
(7.29)
Equation (7.29) is known as the 4"" order Adams-Moulton formula. We need J..,. f., J,.., and f.,_2 to
calculate the approximate value at x,,..1• Like the 4., order Adams-Ba.;;hforth technique, at the begin-
ning they are also calculated using Runge-Kuna method of order fou.r. Equation (7.29) is, however,
an implicit expression. Some algebraic manipulation is, therefore, necessary at each step.
Example 7.9
Consider the initial value problem / = 2 + y - 2x, 0:,; x:,; I, y(0) = L Use 4., order Adan1s-Moulton
method to approximate the sol ution with a step size of 0.1. Compare the results with the exact
solution y(x) = 2x+ e'.
Solutio11
Let/ (x, y) =2+ y - 2x
The first four approximations can be obtained from Rw1ge-Kuna method of order four as shown in
Ex.ample 7.5.
(7.30)
h (9(2+ Yn+I -
y,.., = Y,. + 24 2x,.. , )+ I 9 /,, - sf•. ,+ 1.,-2)
•
Example7.10
Show the absolute errors of Runge-Kutta 4w order. 41h order Adams-Bashforth and 41h order Adams-
Moulton techniques for the initial value problem in Example 7.5.
Solution
The absolute errors of Runge-Kutta 4w order, 4th order Adams-Bashforth and 4 th order Adams-
Moulton techniques are shown in Table 7. l l .
<@> Chapter 7: Initial-Value Problems for Ordinary Differential Equations
Absolute Error
Runge-Kutta Fourth Order Fourth Order
n X Fourth O rder Adams-B ashfortb Adams-MouJtoo
•
0 0.0
1 0.1 0.00000009
2 0.2 0.00000019
3 0.3 0.00000031 0.00000012
4 0.4 0.00000046 0.00000459 0.00000049
5 0.5 0.00000063 0.00001028 0.00000095
6 0.6 0.00000084 0.00001672 0.00000149
7 0.7 0.00000108 0.00002445 0.00000214
8 0.8 0.00000137 0.00003368 0.00000291
9 0.9 0.00000170 0.00004458 0.00000382
10 1.0 0.00000208 0.00005738 0.00000488
■
e. y' = r
~- ( ~ + I, I :,; x:,; 2, y(I} = - l, h = 0.1
2. Solve the foUowing initial-value problem using 4th Order Adams-Bashforth method.
y' = y - x+l+lOexp(- x), 0SxS2, y(0)=- 5, h=O.I
4. Solve the following initial-value problem using 4th Order Adams-Moulton method.
Fourier series analysis is used in solving boundary-value problems, harmonic analysis of vibrations
and electrical current in transmission line and the analysis of input and output current and voltage of
power electronic devices, signal processing, filter design to name a few.
At the heart of Fourier series analysis is the expansion of periodic functions as sum of trigonometric
functions associated with individuaJ frequency components. From the expanded trigonometric sum
each frequency component can be picked up for further investigations.
/(0)
(a)
Chapter 8: Periodic Functions and Fourier Series
/(8)
0
8
~T~
(b)
/(8)
--- T---•I
(c)
Figure 8.1 A g.roup of periodic functions
where ro is the angular velocity in radians per second and r is time in second.
The angular velocity is related to the frequency as ro= 27Cf where f is the frequency in cycles per
second. The frequency f is d1e inverse of time period, T. In angular domain, T = 21r.
A periodic function can be interpreted in angular as well as in ti me domain depending on the
mathematical convenience and need.
8.2 Fourier'sTheorem
A periodic function that satisfies certain conditions (Dirichlet's coruditions) can be expressed as a
sum of a number of sine functions of different amplitudes, phases and periods.
If f (0) is a periodic function with period T ilien
f (0) =Ao+ A, sin(0 +1/>1 )+ A2 sin (20 + 1/12 )+ ···+A,, sin (110+1/>.)+ ·· · (8.I)
an angular frequency of nm, 11 limes the frequency of the first harmonic. A,, is lbe amplitude, 1/J. is
the phase angle of the nth harmonic and nm=n(2n/).
For such representation of /(0) as depicted in Equation (8. 1), lbe number of terms should approach
infinity. However, in most practical applications, the amplitude gets smaller as n gets higher and,
therefore. only a finite number of terms can be utilized without losin_g the desired accuracy.
Using trigonometric identity, the nth harmonic in Equation (8.1) can be split into two terms, a sine
and a cosine, in the following manner.
A,, sin(n0+</J.) = A. cos(n0)sin(</J.) + A,, sin (n0)cos ( </J.,)
=A.sin (<P. )cos(n0)+ A. cos( <P.)sin (110)
=a. cos(n0)+b,, sin(n0)
wlnere
a. =A.sin(</>.,) and b., =A.cos(</>.,)
Equation (8. 1) can be rewritten as
f {0) = Ao +a, cos(0) +b1 sin (0) +a2 cos(20)+b2 sin (20) + ··· +a., cos(110)+b., sin (110) + · ··
= Ao +a, cos(B)+a.i cos(20) + ··· +a. cos(nB)+···
+b1 sin(B) +b2 sin(28) + ·· · +b. sin(nB)+ ·· ·
where a 0 = 2A,i.
There is no mathematical reason for replacing Ao other than using a general format in finding as. The
amplitude and the phase of the 111h harmonic can be expressed as
A. =✓(a.)2 +(b.) 2
and 1/J,, =tan- •(::}
The expression (8.2) is called the Fourier series expansion of f(B). a,, and b,, are Fourier coefficients
of the 11th hannonic.
J- 1'
cos118cosm&d8=0 if n *"'
J_,,• cos118cosm&d8=1t ifn=m
J• cos11.8d8 = 0 for all n
- ,:
First, determine Go· To do this, we integrate both sides of (8.2) from - 7C to 7C. Alternately, you will
get the same result if you integrate expression (8.2) from O to 2n. The selection of the limits of
inetegration is, however, a matter of convenience. The only requirement to be fulfilled is that you
integrate expression (8.2) over one period. This applies to a. and b. as well
J_:f(8)d8 = L: 0
; d8+ L:(t,a. cos118 )d8+ J:.( t,b. sinn8 )d8
f "f(8)d8=1ta +0+0
- ,:
0
•a 0 a J" 0
J-• -2 cosm8d8= -2 -• cosm8d8=0
Chapter 8: Periodic Functions and Fourier Series
Second term:
Third tenn:
n=I
Therefore,
f •J(8)cosm8d6=a,,.1C
-n
a.,= -1 f H
J(8)cosm8d8 m=l,2, ···
JC - •
In order to determine b1, b2' ... multiply both sides of (8.2) by sinm8, where m is any posi tive
integer, and then integrate (8.2) from - 11: to n.
a f"sinm8d8 =O
f_,,•a~sinm8d8
2
=-.J!.
2 -•
Second term:
Third term:
=•
J., I,b. sinn8 sil!lm8d8 = b,. n when II equals III and is zero elsewhere
-•
=•
Therefore,
f ".f(8)sin1118d6= b,.1e
- J<
b,. = -l
1t
f" J(8)si.nm8d8
- lC
m=l,2,···
a0 = -I
77:
f "f( 8)d8
_,,
b., = -
I f,, f(8)sinm8d8 Ill= 1, 2, ···
1C - ,"t
Chapter 8: Periodic Functions and Fourier Series
We can write n in place of III without losing the generality of how to detemune the Fourier coefficients,
a0 = -If •f (0)<10
1f -•
Example8.1
Find the Fourier series of the periodic function /(0) shown in Figure 8.2.
/(8)
0
8
-A
1t 21t 31t 41t 51t 61t
Solution
The periodic function shown in Figure 8.2 can be expressed as
/(0) =A when O<0<n
= - A when n<0<27r
a0 = -
21C
}fO
l• f(0)d0= -j
1C
[ J•f(0)d0 + f l• f(0)d0 ] = Hf •AdB+ f 24 - AdB] =0
O " 1C O "
b. = -I f f(0)s.inn8d0=-I [f "
2,,
Asin118d8+ J (- A)sin118d8 2, ]
1C O 7r O •
2
cosne
b. = -I [ - A- -]" + -l [ A- 110] " = - A [- cos,m+cosO+cos2mr - cos111r)
cos -
1C 11 o 7f II • fl7f
Chapter 8 : Periodic Functions and Fourier Series
A A 4A
b. = - [- cosnn +cosO+ cos2111r - cosnn ]= - [I+ I+ 1 + I]= - when II is odd
ll7r 117r 117t
A A
b. = - [- cos111r +cosO+cos2111r - cosnn]= - [- 1+I+ I- I]= 0 when 11 is even
ll7r 117r
4
n
A (sin0 +.!sin 30+.!.sin50+.!sin 70+·· ·)
3 5 7 •
8.4 Convergence of Fourier Series and Gibb's Phenomenon
Although Dirichlet's conditions provide the foundation for the convergence of Fourier series expan-
sion, the rate of convergence and the manner in which it approaches to f (0) at a discontinuity is of
practical interest in many applications.
Let us consider the Example 8.1. One important question is: how many harmonic terms should be
added to recreate f (0) with a reasonable accuracy? If we consider the first four harmonic components,
we get the following resulting wave shown in Figure 8.3. For graphing purpose, consider A= 5.
,~
..,
J.3
1.,
0
. 1.6
.J.J
••••
·•-" G Ll L5 u !
Now, consider the first eight harmonic components. Figure 8.4 shows the resulting wave.
When we consider the first 20 harmonic components tl1e resulting wave looks like Figure 8.5.
The rate at which a Fourier series expansion converges to tl1e function f (0) dictates how many
harmonic components we should consider for practical applications. Also, it can be noticed from
Figures 8.3-8.5 that at a discontinuity there are overshoots and undershoots. With more harmonic
components added these overshoots and undershoots get sharper but they never disappear, an
important observation known as Gibb's phenomenon. Hence, for practical applications, some kind
of filtering may be utilized to smooth out these over- and undershoots.
Chapter 8: Periodic Functions and Fourier Series
'-"
4J
J.J
u
0
, 1.6
.J.3
~-•
.,.s
• u u u 5 ,.J 7.5 I.I u u
Figure 8.4 Re-creation of a square wave with the first eight
harmonic components
6.5
1.6
-6.$+ - - - - ~ - - - ~ - ~ - - ~ - - - - - ~ - ~
Q l.3 2..5 3.S 5 '--3 7~ 8~8 10 it ll
/(0)
/(0)
e
Figure 8.7 Odd function
The Fourier series of an even function f (0) is expressed in terms of a cosine series.
i.e., f (0) = i + I,a. cos110
11= 1
The Fourier series of an odd f~nction / (0) is expressed in terms of a sine series.
i.e., f (0) = L,b. sinn0
Example8.2
Find the Fourier series of the periodic function f(x) in Figure 8.8.
/{x)
Solution
l• l• , l..r3 •=• 2 0
a0 = - f J(x)dx= - f x- dx= - - =- n -
7C - • 7C - • 7C [ 3 ] 3
.x=-ll
a.= -I
J't
J•f(x)cosnxdx=-l [J
- II '/C - R
n x 2 cos11xdx ]
I= fx 2
cosnxdx=x
2
f cosnxd.x - J{;(x )J cos,udx }dx 2
I = -x2 Slfl/lX
. 2
--
JXSUIIU'
. d·x
II II
2
x • 2x 2 .
I= - SID/IX+ COS/IX - J SJn nx
2
n n n
a• = -
7t
l. [ x- .
- '
11
Slll /IX
2x
JI
2 .
+ 2 COS /IX - - 3 S10 /U'.
JI
]"- Jr
4
= - 2 COS Jl7C
fl
4
a,.= - 1 when II is odd
n
4
a =- 0 when 11 is even
" II-
n2
-3 - 4 cosx
( cos2x cos3x cos4x
22 + 32 42
+···) •
Chapter 8: Periodic Functions and Fourier Series
Example8.3
Find the Fourier series of the perioilic function f(x) in Figure 8.9.
ftx)
Solutio11
a 0 = -I f 2"
f(x)dx= -2 f "sinxdx = -4
TC o TC o TC
Using the angle. time relationships shown above, the Fourier coefficients of the periodic function
.f (t) of period T arc given by
T
a0 = -
2 ?
T _!.
r-
f(t)dt
2
n= I, 2, ...
~
f(t)=a 0 + ..i::.,a,,cos (- ~ . (211:11
211:11- / ) + ..i::.,b,,sm - - - t)
n=I T r,:J T
Example8.4
Find the Fourier series of the periodic function /(t) in Figure 8.10.
fl()
f(!) =I when
T
- - $/$ -
T
4 4
=- t+ -
T when -T $/$ -3T
2 4 4
and J(t+T)=J(t)
Solution.
This is an odd function. Therefore, a,. = 0.
T
2 2 2
b,. =!fr/(1)sin ( f(t)sin( 1tn 1)d1
11
T O
1t
T
1)d1= ~J
T o· T
Chapter 8: Periodic Functions and Fourier Series
b,, = -4 J isin ( - f
2,rn
-, ) dr+ -4 - 1+ - sin ( -
21r11 ff(
-, ) dt T)
To T T!. 2 T
4
f . ( 2nn
/Slll - -1 ) dt
T
=f JS1ll. (2nn
- -1 ) dt +-T- Jcos( -
T
21r11
-/ ) dt
2m1 T
1
=---rcos
T - -t ) +( -T-) sm
(2n:n . (-
2nn
-t )
2n T ~11 T
Therefore,
ff Ism. (2m,
- -1) dt= [ - -T-/cos (2nn
T
- -1) + ( -T-)
2nn T 2nn
2
• (-
sm 2nn
T
-t )]f
0 0
2n) + (2nn
2 2
11
T cos (
= - 81r11 T ) • ("1t)
sm 2
Jf . (2ml )]f
2
)
- f Slll - -t dt = [ T - - f COS - - / (21m ) ( T - - -) •(21t11
Slll - -f
!. T 2nn T 21tn T r
• 4
1
T -cos (nn)
1, 1 1. (ll7r)
= -T -cos(111r) - ( -T-) sm(111r) - - - + ( -T-) Sill -
4nn 2nn 81r11 2 2nn 2
- -r )]f
ff -T sin. (2m1
- -r )dr = [- -
T -cos (2m1
1
! 2 T 41t11 T T
4 4
= --
4nn
2
T -cos(111r}+ -T -cos -
4nn 2
1
("n)
b _ 4[2( T )
"
- -
T
- -
· 2nn
2
I • (11,r)]
Slfl -
2
-- -
2T .
-SID
11
2
n2
("n)
-
2
•
Chapter 8: Periodic Functions and Fourier Series
=a,. - -
2- -
Denoting
a (a" -2;·b" ) and c_,, = (a" +;·b
c0 = i 2' c• = 2 '
) 1
c,. = ( a• - jb• ) = - J
2 2ir -•
J" j
f(9)cosn9d9 - -
2ir -•
J"
f(9)sinn9d9
=-I J"
2ir _,,
f(9)(cosn9 - jsinn9)d9
=-
1
2ir -•
J"
f(B)e- 1" 6 dB
Similarly,
Chapter 8: Periodic Functions and Fourier Series
Co= - l
2n-
J•f(0)d0
- ;r
2n- -•
and the complex form of the Fourier series expansion off (0) with period 21t is:
Example8.S
Find the complex Fourier series of the periodic function f (0) shown in Figure 8.2.
Solutio11
The periodic function shown in Figure 8.2 is a square wave that can lbe expressed as
f(8) =A when 0<8<n-
=- A when 1t<0<2n-
and due to its periodicity, f (8+ 2n) = f (8).
c =-
"
-J
1
2;,r
2
0
" f (0) e-1" 8 d0
c. = __:!:___
2n-
J 2
0
• - f.Ae-
f (8)e-;,, 8 dB = - 1
2,r O
1" 8 d8+ - -·
1
2n-
Ii" ..- Ae-;nB dB
Chapter 8: Periodic Functions and Fourier Series
n=-
ifr(t+lfl)=l/>(t)
If lhe representation contains both sine and cosine terms, then it is called a full-range series. However,
we may incorporate the repetitions in such a way that the representation can be made up of either
sine terms only or cosine tenns only. In this case, it is called a half-range series.
Let us examine Figure 8.11 that contains f (1) and its extension ¢(1). cf>(r) is neither odd nor even
and, therefore, its Fourier series expansion will contain both sine and cosine 1em1s.
ft.r ) /(1)
0
(a) (b)
Figure 8.11 (a) A finite interval function and its (b) fulj.
range periodic extension
Chapter 8: Periodic Functions and Fourier Series
<p(I)= -A - ~
£_,- A SID
. (2nn
- ()
2 •=•111C lfl
However, /(1) is only valid in 0<1 < lfl
The periodic extension off(r) can be done in such a way that the extension ¢(r) becomes an even
function as shown in Figure 8. I2. In this case the Fourier series expansion will contain only cosine
tenns.
_/{I) f(t )
A
0 'II
(a} (b}
Figure 8.12 (a) A finite interval function and its (b) even
half-range periodic extension
ip(t)= -A - ~
£.., -4A- ,cos (nTC
- l)
2 ,,.-(111r) lfl
~ -( 4A
A - -'-'
f(t) = - - 2 cos(nTC )
- I . 0<1<1/f
2 ,r-odJ n 1C ) If/
The periodic extension of /(1) can be done in such a way that the extension ¢(1) becomes an odd
function as shown in Figure 8. 13. In this case the Fourier series expansion wilJ contain only sine
terms.
The Fourier series expansion of the odd half-range extension 1/)(r) is
,/(I) /(1)
A A
It should be noted that in all three cases the Fourier series expansion, converges to f (t) only within
the interval O< 1 < 1/f.
j[_x)
- it 0 3n 51t X
2. Find the Fourier series of the function /(1) shown below. Show the first 12 non-zero har-
monic terms.
}[_I)
4. Find the Fourier series oflhe function f(t). Show the first 12 non-zero harmonic terms.
f{x)
6. Find the Fourier series of tl1e function f (t) shown below. Show the first 12 non-zero har-
monic terms.
f(t) =500At O St ST, f(t+T)=J(t), T=2 ms
./(/)
0 T 2T 3T f
Chapter 8: Periodic Functions and Fourier Series
7. Find the Fourier series of the periodic function f (x) shown below. Calculate the coefficients
of the first 12 non-zero ham1onic components.
fl.x)
X
Sn
8. Find the Fourier series of the periodic function/ (x) shown. below. Determine the first 12
non-zero tem1s. Considering the amplitude of the fundamental component as 100, express
the other hannonic components as a percentage of the fundamental.
./{x)
10. Find the Fourier series of the periodic function f (1) of period T.
J(1)=r - 2s1s2. T=4
11. Find the Fourier series of the periodic function f (1) of period T.
(9.1)
Example9.1
Determine the eigenvalues and eigenvectors of matrix A shown below.
Solution
First, set up the characteristic equation.
,l -1 2 -4
1i 1- A I= -I ,l - 2 - J =0
0 - 1 ,l+l
0.618 2
[
-l
0
-0.382
- I
-]
-4
2.618
l[ l
x,,
X11
Xu
=0
[
x ,,
X12
X 13
l l
=
[ -0.5809
0.7604
0.2904
For~ =I
Chapter 9: Eigenvalues and Eigenvectors and their Applications
[
X1 ,
X22
X23
l[ l
=
0.8018
--0.5345
--0.2673
l[ l
The normalized eigenvector corresponding to the eigenvalue ~ =--0 .6 18 is
X3, 0.8817
X 32 = --0. 1684
[
X 33 --0.4408
Now, we will discuss another method of finding eigenvectors. For this method, we will rewrite
Equation (9. 1) for each eigenvector.
{,\1-A)m' =0 (9.3)
3
We know Lhat KK-' = I and also K- 1 = ~~
_, adjK
Therefore, KK = K 7ir =I
KadjK = IKII
( i!.11- A) adj( il,I - A) = Ii!.11- All
I
However, i!.11- Al is equal to zero since it, is an eigenvalue.
Therefore, we can write
(9.4)
A comparison of Equations (9.3) and (9.4) sbow that the eigenvector m1 is proportional IO any
nonzero column of adj (il;I - A). ■
Example9.2
Find the eigenvalues and the eigenvectors for the system with a system matrix A.
A=[ - -~
13
~I ~
0
l
Chapter 9: Eigenvalues a nd Eigenvectors and their Applications
Solution
The characteristic equation is
l+5 - 1 0
Il l -Al = 0 A+4 - I =0
13 -1 A
(9.3)
- 2.9376 -0.5625
[ 10031
adj(A,1- A)= - 13.0409 - 2.4969 4.4533
-44.8518 - 8.5876 15.3162
l
-4.6634 - 2.2327 09546
[
adj(A..il- A) = -12.4099 - 5.9415 2.5403
l
l
- 20.6143 - 9.8696 4.2198
All columns of the adjoints are non-zero ones. Therefore, we may pick any column as an eigenvec-
tor. Let us pick the third column from each adjoint.
l[ l
The eigenvector for A, = -0.5607 is
11
xX = 1.003 l
4.4533
12
[ X13 15J](i2
The eigenvector for
[
X21
X22
X23
l[ l
Ai = - 2.3389 is
=
0.9546
2.5403
4.2198
The eigenvector for~ =-6.1004 is
[
X31 ] -
X32
X3J
-
l[ 0.9915
- 1.0911
2.2918
In the following sections, the application of eigenvalues and eigenvectors will be discussed. ■
Chapter 9: Eigenvalues and Eigenvectors and their Applications
R L
Therefore,
(9.5)
Where
v11 (r) = voltage drop in the resistance, Rat time I
vL (t) = voltage drop in the inductance, Lattimer aud
dt C
f
v1 (r)= Ri(r)+ L di(r) +..!._ i(t)d1 (9.6)
Chapter 9: Eigenvalues a nd Eigenvectors and their Applications
Differentiate Equation (9.6) with respect to time. The mathematical model of the system is:
2
dv, (I)= Rdi(t) + L d i(r) + i(t)
(9.7)
dt dt dc 1 C
A force applied to the mass, M in the direction of x wiU be balanced by three other forces in the
opposite direction of x. The balancing forces are the gravitational force on the mass, the damping
force due to the shock absorber and the spring force.
d 2 x(r) dx(r)
or, M ? +B- -+Kx(r)=- Mg (9.IO)
dr dr
Chapter 9: Eigenvalues and Eigenvectors and their Applications
Assume linearized How rates. Therefore, the How rates can be considered proportional to the
corresponding liquid heights. If R, and R2 are constant resistance factors of the control valves C,
and C2 then
(9.12)
If V, (t) and V2 (t) are volumes of li,quid in tanks l and 2 respectively and q, (i) is the inflow in the
first tank then
(9.14)
Equations (9. 14) and (9.15) mathematically model the dynamic bebaviour of this two-tank liquid
level system.
Chapter 9: Eigenvalues and Eigenvectors and their Applications
where A is the nxn state matrix and B is the 11x111 input matrix.
It is important to note at this point that although the entire 11-dimensionaJ state vector x (1) characterizes
the complete internal behaviour of a state-space system, it is usually impossible to directly measure
or observe all n components of x (t). The external output vector can be expressed as
L{i,(t)}
L {.i:,. (t)}
where
Using Equation (9.22), the transfer function matrix can be written as,
G Cadj{sI-A) B
(9.23)
(s) Isl-A l
The dynamic system modeled by Equations (9.18) and (9.20) is stable if all the roots of the
characteristic equation isl- A I= 0 lie on the left half of the s-plane. The roots of the characteristic
equation, isl- A I= 0 are called the eige11val11es of the system coefficient matrix (system matrix) A.
That means the eigenvalues of a stable system are all negative.
Example9.3
Consider a 2-dimensional system with the following system and input matrices.
Solution
(s1- A) = [ s -3 ]
2 s +5
(sl-Af' = adj(sl- A) l [ s+ 5 - 2 ]
2
isI-AI s +5s +6 3 s
The transfer function of the system is
G (s) = [, l O ][ s+ S 3 ][ I ] s+ 5
s- + 5s+6 - 2 s O - (s + 2)(s+3)
The roots of the characteristic equation, i.e., the eigenvalues are - 2 and - 3. Both eigenvalues are
negative, therefore, the system is stable. ■
Chapter 9: Eigenvalues and Eigenvectors and their Applications
y= CTz (9.25)
PremuJtiply Equation (9.24) by T- 1•
T -'T :i = T -'ATz + T-'Bu
In order to solve for each state, we have to integrate each equation. Integrating the second term on
the right-hand side of the equation should be done with little difficulty. However, the integration
of the first term on the right-hand side cannot be done that easily. Because, we.will have to wai t for
Lhe determination of other state variables. Now consider a coefficien I matrix, A with only diagonal
elements, all other elements being zero.
Each individual equation as shown in the matrix form can be expressed in tenns of its self-terms
onl y. Therefore, each equation can be integrated with little difficulty.
.x1 (1) = A11 x 1 (1) + 8 11111 (1)+ B12ui(1) + · ··+ B,,.11., (1)
x2 (1) = Anx2 (1) + B2I u1 (1) + B12112 (1) + ·· ·+ 8 1mu., (1)
x3 (1) = A33 x 1 (1)+ B31u1 (1) + B3211.i (1) +···+ B1.,.u,. (1) (9.26)
The set of Equations (9.26) represents a system model that contains only the self-terms. All mutual
tenns are zero. This type of system is often called a decoup led system. It is relatively very straight-
forward to carry out mathematical analysis of a decoupled system.
We are, therefore, interested in a particular type of coordinate transformation that will transfonn our
coupled system into a decoupled systeDL We have already discussed that the transfer function matrix
Chapter 9: Eigenvalues and Eigenvectors and their Applications
and the characteristic equation wou11d remain unchanged even after this transformation. Assume that
th.is transformation can be achieved with the belp of a transformation matrix M .
m,, 111,2
11121 "'22
M=
M-'AM =A
MM-'AM =MA
AM=MA
All A,2 A,. m,, T/112 ,n,n m,, llln 111,,, ..t, 0 0 0
Ai, Ai2 Ai. m2, 11122 m211 lll2 1 111 12
"½. 0 ~ 0 0
=
0 0 0
A., An2 Ann ltlnl tnn2 111,m lll,, 1 111n2 ,n,m 0 0 0 ..t,.
Equate columns on both sides. Equating the 2nd column we can write
(9.28)
(9.29)
Equation (9.29) can be solved to find the ith column of d1e transfom1ation matrix M . Observe diat
associated widi each eigenvalue there is a corresponding colwnn or vector for die transformation
matrix M . These vectors are d1e eigenvectors of die system. The transformation matrix M diat
diagonalizes die system matrix A is called the modal matrix. The state variable z is called canonical
wlnen the coefficient matrix becomes diagonal.
Example9.4
Find die modal matrix diat will transforms die coefficient matrix A in Exan1ple 9.1 into a diagonal
matrix. Verify that the modal matrix transfom1s A into a diagonal matrix.
Solutio11
We already have die diree eigenvalues as
J., = 1.618, ~= I and Ai =-0.618
l[ l[x l[ l [xl[ l
The corresponding eigenvectors are
21 31
X11
x, = -0.5809
0.7604 , x 22 = 0.8018
-0.5345 and x32 = 0.8817
-0.1684
2
[
X13 0.2904 X23 -0.2673 X33 -0.4408
M=
-0.5809 0.80 I8 0.8817
0. 7604 -0.5345 -0.1684
[ 0.2904 -0.2673 -0.4408
l
For verification purpose, multiply the following.
M-'AM
1
M- AM =
[ --0.5809 0.8018 0.8817
0. 7604 -0.5345 -0. I684
0.2904 -0.2673 - 0.4408
n 1 - 2 4 ][ --058~ 0.8018 0.8817
l 2
0
I
I -I
0.7604 -0.5345 -0. 1684
0.2904 -0.2673 -0.4408 l
[ 24914 1.5397 4 3946 ][ 1 - 2 4 -0.5809 0.8018 0.88 1' ]
M-'AM = 3.7417 0 7.4833 1 2 I 0.7604 -0.5345 - 0.1684
-0.627 1.0145 - 3.9099 0 l -1 ][ 0.2904 -0.2673 -0.4408
Chapter 9: Eigenvalues and Eigenvectors and their Applications
l
0.2904 -0.2673 - 0.4408
1.618 o o
M-'AM = 0 1 0
[ 0 0 -0.618
Solution
A=
[ -l
0 -4
- 13 l ! l
1 +5 - I 0
111- A I= 0 1 + 4 - I =0
13 - I 1
(9.30)
adj(1i - A)=
[ -4 6634
- 2.2327
09546
- 12.4099 - 5.9415 2.5403
- 20.6 143 - 9.8696 4.2 198
l
11.7133 -6.0487
>ij(.l,1- A) • [ - 12.8897
o.,,,,
6.6562 - 1.0911
l
All columns of the adjoints are non-zero ones. Therefore, we may pick any column as an eigenvector.
Let us pick the third column from each adjoint.
Chapter 9: Eigenvalues and Eigenvectors and their Applications
[
11
xXn
x, 3
l[ l= 1.003 I
4.4533
15.3162
l[ l
The eigenvector for A.,- =-2.3389 is
~
X21 0.9546
X22 = 2.5403
[
X23 4.2} 98
[
X 31
X32
X33
l[ l
The eigenvector for ,ti =-6.1004 is
0.99[5
= -l.0911
2.2918
Note d1at the eigenvectors determined above are not normalized ones. i[f necessary, they can, however,
be normalized.
The modal matrix widJout nomializing the eigenvectors is
l
[ 1.0031 0.9915
0.9546
M= 4.4533 2.5403 -1.0911
15.3162 4.2198 2.29 18
l
[ --05601 0 0
M-'AM= 0 - 2.3389 0
0 0 -6.1004
l[ l [ l
The eigenvalues of A are I .303, - 2 .303 and 2. The corresponding eigenvectors are:
~.172 ~.557 o
0.891 , ~.467 and 0.894
[ 0.420 0.687 0.447
M=
~.172 ~.557
0.89 1 ~.467 0.89~
[ 0.420 0.687 0.447
l
M diagonalizes A and setting Y = MZ transfonns Y = AY into Z =AZ
where
A=M-'AM
1.303 0
A= 0 - 2.303
[ 0 0
z, -- ae•=•
- be-1..303,
Z2 -
Therefore.
ae1.303,
z= be- 1.303,
l
Since Y=MZ
3
-0.172 -0.557 O l [ ae'.30 '
Y= 0.891 -0.467 0.894 be-1 ·:,:n,
[ 0.42 0.687 0.447 ce 2'
The arbitrary constants a, band c can be found if initial condition is given. Given an initial condition,
Y (0) = [ 0 0 Ir we have the following.
-0.I72a-0.557b =0
0.89 la - 0.467 b + 0.894c = 0
0.42a +0.687b+0.447c= J
k,
111, - - - - - - - - - -
yI
-----
-r-- .
·•
k,
Masses Displaced
Assume that there are no damping and external forces acting on the sys1em. The motions of the
masses arc governed by the foUowing differential equations.
Y, =- k,y, +k2 (Y1 - y,) = - (k, + k2)Y, +k1Y2
Y2 = - kl (.1•2- Y,) = k2Y, - k1Y1
where y, and y2 are functions of time I and the dots denotes derivatives with respect to time. In matrix
form the equations can be written as
.. =AY where A= [ - 5 _3 ] .
Y
3 3
Let us try Y =e"'' C as a solution where w wiU be determined and C is an unknown constallt matrix
=
Substituting Y e"''C into the differential equation Y =AY gives ns
(9.31)
wlnere A=w2
Equation (9.32) shows that C must be an e igenvector corresponding to eigenvalue A for Y =e•·•c
10 satisfy the differential equation Y = A Y . Therefore, the next step would be to solve for the
eigenvalues of A . The eigenvalues are Ai =--0.838 and Ai = - 7.162. Corresponding to 1 1 =--0.838
.
we get ti1e e1genvec1or [ 0.585]
_
0 811
Y, =[acos(.J0.8381)+bsin(.J0.8381)J[ ~:~~~ ]
(9.35)
y = [ 0.585acos( J0.8381 )+ 0.585 bsin( .J0.8381) + 0.81 Iccos( ,J7. 1621) + 0.81 Id sin ( .J7. 1621)
0.81 la cos( .J0.8381 )+ 0.811 bsin ( .J0.8381 )- 0.585ccos( ✓7 .1621 )- 0.585d sin ( ✓7. 1621)
l
In tenns of individual displacement
y, = 0.585acos( ✓0.8381 )+0.585bsin ( ✓0.8381 )+ 0.81 Iccos ( ✓7. 1621 )+ 0.8Ud sin ( ✓7. 1621)
y1 = 0.81 I a cos (.J0.8381 )+ 0.8 1 I bsin ( .J0.8381 ) - 0.585ccos(✓7.1621 ) - 0.585d sin(.J7. 1621)
We can determine the values of a, b. c and d if we know the initial position and initial velocity.
Assllllle the foUowing initial conditions.
Y,(O)
[ y2 (0)
]=[ I ] and [ j , (O)
1.5 j•2 (0)
]=[ 2 ]
3
With these initial conditions. we get a= l .802, b = 3.936, c =--0.067 and d =-0.05.
y, = J.054cos ( ✓0.8381 )+ 2.303siu( ✓0.8381 ) - 0.054cos( ✓7. 1 621 ) - 0.041sin ( ✓7. 1621)
y 2 = l.461 cos ( .J0.838t)+ 3. 192sin {.J0.8381 )+ 0.039cos(✓7. I 62/) +0.029 sin (.J7. 1621)
Chapter 9: Eigenvalues and Eigenvectors and their Applications
Definitions:
Symmetric Matrix: A symmetric marrix is a square matrix that satisfies AT = A
The eigenvalues of a real symmetric matrix are real.
Orthogonal Mmri:r: A real matrix A is called orthogonal if its transpose AT coincides with the
.
inverse A-'.1.e., AT= A-'.
I,aklakf = 0 for i *j
k=-1
2. The sum of the squares of the elements of each row (column) of an orthogonal matrix is
equal to unity.
" .
I,a,! = I,a! = I
3. The determinant of an orthogonal matrix is equal to ± I.
4. The transpose and the inverse of an orthogonal matrix are also orthogonal matrices.
physics and analytic geometry. In many cases we want to write this polynomial expression in a more
compact form, specifically in self-terms 011I y. This requires a coordinate transfonnation.
The first step towards a coordinate transformation is to arrange the polynomial expression into a matrix
• •
expression. The polynomial expression, I, I,agx,x 1 will include sq11are tenns a11 x~ , a22xi, · · ·, a..x~
}=I /:I
and product (mixed) terms.
( afl + aJI )xrt 1 , i *j and can be written as a matrix product XT AX, where A is a real symmetric
matrix.
x,
X= x2 and the elements of A can be folllld in the following manner.
X
•
A11 =a0 for i= 1, 2 , · ··, 11 and
Alj =(a., +ap)l2, i7"j.
Let 11s consider a quadratic expres sion - 12x~+6x,x 2 + 2xi + 5x,x 3 - 4x2 x 3 + 7xl . This expression
can be written as:
The second step is to find the coordinate system where this quadratic expression can be expressed
in self-terms only.
Theorem: If A is a real symmetric matrix then its modal transfonnation matrix is orthogonal.
Start with the quadratic expression in matrix form, XTAX. Let Q be the modal transformation
matrix that diagonalizes A. The change of coordinate is achieved with the transformation, X = QY.
Therefore,
XTAX=(QY? A(QY)
= YT(QTAQ)Y
= y T(Q-1AQ) Y
•Y'[1: ly I
= 1,i + Ai Yi +·· ·+ 1.Y!
Chapter 9: Eigenvalues and Eigenvectors and their Applications
The result, termed as the principal axis 1heorem, illustrates the application of a new axes system
with respect to wb.ich the quadratic form has a particularly simple appearance. The resulting expres-
sion with self-terms is termed as the standard form.
Let us continue with our previous quadratic expression which was written in the following matrix
form.
l
Note that the coefficient matrix A is symmetric.
- 12 3 2.5
A= 3 2 -2
[ 2.5 - 2 7
0.243
Q = 0.934 -0.289
[ 0.263
0.077 -0.967
0.954
0.2 12
0.142
l
The eigenvalues are 2.2 18, 7 .807 and - 13.024 and the corresponding modal transformation matrix is
The new axes system is related to d1e old axes system in d1e following manner.
Example9.6
Consider the quadratic expression xf - 4x1x2 + xJ. Transform the expression into its standard
fo:rm.
Chapter 9: Eigenvalues and Eigenvectors and their Applications
Solution
First write the quadratic form
A=[ - 21 -21 ]
The eigenvalues are 3 and - 1. The modal transformation matrix is Q =[ 0. 7o7 0. 7o7 ].
~.707 0.707
Every 2 by 2 orthogonal matrix Q,=[ ~:;~; ~:;~; ] is a rotation of the plane and represents a
counter-clockwise rotation of 45 Degrees.
Using X = QY, the quadratic expressionXTAX is transformed to its :standard form, 3y: - Yi.
The required transfonnation in coordinate form is
x,= 0.707y,+0.707y2
X2 = - 0.707)'1 +Q.707 y1
)'1=0.707x1- 0.707x2
y2 =0.707x, +0.707x2
The equation x: - 4x1x 2 + xJ = K re.presents a conic in the plane. Figure 9.5 shows a contour plot in
its original form. Figure 9.6 shows the conic in its original as well as with respect to the new axes
systems. A contour plot of the standard quadratic form is s hown in Figure 9.7. ■
x,
Example9.7
Analyze the conic 6x: - 2x1x 2 + 2xi = 9 utilizing standard quadratic form.
A=[ -I6. - I ]
2
The eigenvalues are 6.236 and 1.764. Using X = QY, the quadratic ex.pression XTAX is transfonned
y:
to its standard form, 6.236 + I. 764 = 9. Yi
? ?
__K_+ Yi =l
1.443 5.102
, '
Y, + Yi
(J.201)2 (2.259)2
In its standard fom1 we can easily recognize the conic to be an ellipse. The intercep1s with Yi and y2
are ±1.201 and ±2.259 respectively.
The modal transformation matrix (which is orthogonal) is
Q =[ 0.973 0.23 ]
-0.23 0.973
Every 2 by 2 orthogonal matrix is a rotation of the plane and Q=[ ~t~! 0.23
_
0 973
] represents a
x, = 0.973 y, + 0.23 Yi
X2 =-0.23)'i +0.973y2
Yi =0.973 x, - 0.23x2
Y2 = 0.23x1 + 0.973x2
Figure 9.8 shows a contour plot of the conic 6x~ - 2xix 2 +2.t; aa 9 in its original form. Figure 9.9
shows the conic in ilS original as well as with respect to the new axes systems. A contour plot of the
conic in its standard quadratic fonn is shown in Figure 9.10. ■
Chapter 9: Eigenvalues and Eigenvectors and their Applications
10
•
•
4
-2
-4
-•
-8
- 18
- 0 -8 -<l ... -2 0
• •
1. x~ + 2x,x2 + 6xJ
.. + x. 2
2 . x 12 - 4 x,x~ 2
_J
CHAPTER 10
8 DA R ry A u p O8 L Ms-+-----+---+--- ----+--<-t-1
The boundary conditions y(a)=Y. and y(b)= Y,, are conditions imposed on y (x). They are called
Dirichlet boundary conditions. In some cases boundary-value problems have conditions on the
derivative of y(x), e.g. y' (a)= a and y'(b) = {3. These boundary conditions on derivative are called
Newmann boundary conditions.
Example 10.1
Solve the following boundary-value problem
y'=2y'+ y - 6cosx - 2sinx, 0~xSn/2 y(0)= l and y (n/2)=2
Solutio11
Substitute z, = y and Z2 = y' = z;.
Set the initial conditions as z, (0) = y (0) = l wh.ich is already given.
Let the second initial condition be z2 (0) = y' (0) = 1. If this initial condition does not satisfy the
boundary condition y(n /2) = 2, we will try a different one in the second trial.
Chapter 10: Boundary-Value Problems and Partial Differential Equations
The initial condition of ;:1 (0) = y'(0) = I does not satisfy the boundary condition y(n/ 2) = 2.
Therefore, try z1 (0) = y' (0) = 3. We get
y(0)=l, y' (0)=3, y (n/ 2)=13.24464139
ObviotL~ly, none of our two choices of the initial slope satisfied the boundary condition y(n/ 2) = 2.
However, by using Equation ( I0.1 ), we can utilize their solutions at the boundary point to detennine
the required slope.
The required initial slope is
2 (3 - l) - {(-6.12508577) 3- 1(13.24464139)}
p= {13.24464139- (- 6.12508577)}
p = 1.83894685
Therefore, wilh y(O) ;;;; l, y'(O) ;;;; 1.83894685, lhe solutioa to the boundary-value problem is showa
in Table I.
For better accuracy, we can utilize Runge-Kuna method of order four. For the same step size h = n/ 20
we get
y(O)=l, y'(O)=l, y(ir/ 2)=- 13.48910815
p= 1.99993452
Therefore. with y (O) = 1, y' (0) = 1.99993452, the solution to the bmrndary-value problem is shown
in Table 2.
Table 2 Solution to the boundary-value problem using Runge-Kutta method of order four
Theorem
If p(x), q(x) and r(x) are continuous fw1ctio11s on [a, b] and q(x) > 0 on [a, b], then the linear
boundary-value problem of the following form
/' =p(x)y'(x)+q(x)y(x) +r (x), a._,;x._,;b, y(a) =Y,, and y(b) =Yb,always hasasolution. ■
The solution to the original boundary-value problem can be written as a linear combination of two
so lutions as
(10.2)
where
y, (x) is the solution to the initial-value problem
y'=p(x)y'(x) +q (x)y(x) +r(x), a._,;x._,;b, y(.a) =Y. and y'(a) =O, (10.3)
(10.5)
(10.6)
Since y, (x) is the solULion to (10.3) and y2 (x) is the solution to (10.4), we can substitute them in the
original equation. TI1erefore,
y'(x) = p(x)y'(x)+q(x)y(x)+r(x)
Example 10.2
Solve the following boundary-value problem
yK= 2y' + y - 6cosx - 2sinx, Q._,;x ._,; n/2 y(O) =l and y(n /2) = 2
Compare the results with the exact .solution _v = cosx + 2sinx, 0 ._,; x ._,; n/2.
Chapter 1 O: Boundary-Value Prob lems and Partial Different ial Equations
Solution
Convert the boundary-value problem to t\vo following initial-value problems.
y'=2y' + y - 6cosx - 2sinx. 0,S,x<S,n/2 y(O) =land /(0) =0, ( I0.7)
Use Runge-Kuna method of order four, and JO steps to solve the two initial-value problems.
Combine the solutions of (10.7) and ( 10.8) using Equation ( !0.2) to obtain the solution of the
boundary-value problem. Table 3 shows the results of the two initial-value problems and the
boundary-value problem.
The technique based on Equation ( I0.2) is susceptible to round-off errors. Jn some cases better
results can be obtained by applying the technique in reverse order. In reverse order Lhe two ini-
tial-value problems become
y' =p(x)y'(x)+q(x)y(x) +r(x), a<S,x<S,b, y(h) =Yh and y'(b)=O, (l0.9)
y'=p(x) y'(x) +q(x) y(x), a<S,x<S,b, y(b) =O and y'(b) =l. (10.10)
Table 4 shows the results of the two initial-value problems and the boundary-value problem when
solved in the reverse order, again in 10 steps.
Even though the technique applied in the reverse order produced better resul ts than the results
obtained in the normal order, this for many applications may still be unacceptable. For such cases.
you may reduce the step size or apply technique shown in Equation ( 10.1).
Chapter 10: Boundary-Value Problems and Partial Differential Equations
n X Y. Absolute Error
y """'
0 0 I I 0
l 0.15707964 l. 27524851 l.30055728 .02530877
2 0.31415927 1.52001172 l.56909052 .04907880
3 0.47123891 1.72872238 l.79898754 .07026516
4 0.62831855 L.8969l054 1.98458752 .08767697
5 0.78539819 2.02141034 2.12132036 .09991001
6 0.94247782 2.10057931 2.20581925 .!0523994
7 1.09955746 2.13454529 2.23600355 .10145826
8 l.256637 JO 2.12550503 2.2 1113002 .08562498
9 1.41371673 2.0781 l084 2.13I81112 .05370028
JO 1.57079637 2.00000000 2 0.0
has the solution y(x) = e 2' - e·'. Use the linear shooting method that uses Equation (JO. I) and
h = 0.2 to approximate the solution and compare the resuJts to actual solution.
2. Repeat Problem l with h = O.l.
3. The boundary-value problem
y' = y' +2y - cosx - 3sinx, - 1:;;x ::;o, y(- J) = I.8768Jl and y(O)= l
has the solution y(x) =sinx+e·•. Use the linear shooting method that uses Equation (10.2)
and h = 0.1 to approximate the solution and compare the results to actual solution.
4. Repeat Problem 3 with h = 0.05
5 . Solve boundary-value problem
y'= 2y'+3y+2 - 4x - 3x 1 , o::;x::;2, y(O)=Oand y(2)=4
using the linear shooting method that uses Equation (JO. I). Use (a) h=0.2. (b) h=O.l.
6. Solve boundary-value probJ.em
using the linear shooting method that uses Equation (102). Use (a) h = 0.2, (b) h = 0.1.
Chapter 1 O: Boundary-Value Prob lems and Partial Different ial Equations
where p0 and p1 are the respective guess values for the unspecified initial value of y' (a).
We can then use the Secant method to find an improved guess value for the unspecified initial value
of y' (a) using the following sequence.
Example 10.3
Solve the following boundary-value problem
We can accept p 10 = - 0.15 170578 as the initial slope (unspecified initial value) to provide the
solution to the boundary-value problem with a tolerance of 10· 1 • The results of the boundary-value
problem obtained with this initial value of y'(- 2) = - 0.15 I70578 are shown in Table 5.
The order of a partial differential equation is the highest order of deriv ative which appears. A partial
differential equation is called linear if the unknown function and the partial derivatives are of the
first degree and at most one of these appears in any given term. Otherwise, the equation is caJJed
nonlinear.
A general Linear partial differential equation of order two in two variables can be expressed as
Hyperbolic: B2 - 4AC>0
Only a very few simple boundary-value problems for linear partial differential equations can be
solved using analytical techniques. The analytical techniques utiJize !he techniques of the separa-
tions of variables, superposition principle and Fourier series expansion. Due to the Limited use of
these analytical techniques, numerical solutions are sought to solve a vast majority of the physical
problems.
Theorem:Superposition Principle
If 111 and 112 are solutions of a Linear homogeneous partial differential equation, then any linear com-
bination of 111 and 112
11=c,11, +c2t½ is also a solution,
where c, and c2 are constants. In addition, if u, and 11 2 satisfy a linear homogeneous bow1dary
condition, then the Linear combination 11 = c ,111 + ~ u2 will also satisfy the boundary condition.
Chapter 1 O: Boundary-Value Prob lems and Partial Different ial Equations
The boundary conditions are: u(0,1) = 0 and tt(L ,t) = 0 for all I> 0.
011
The initial conditions are: u(x,O) = f (x) and (x,O) = g(x) for O< x < L.
cJr
The boundary conditions state that the ends of tbe string are held fixed at all time. The initial condi-
tions give the initial position (shape) of the string f (x), and its initial velocity g (x).
u
u(x, 0) = f(x)
X
0
Figure 10.1 Initial shape of a stretched string
u(x,t)=X(x)T(r) ( 10.12)
where X ( x) is a function of x alone and T (t) is a function of I alone. The problem, therefore,
becomes finding X (x) and T (t). Differentiating u(x,t) = X (x) T(t) with respect to x and I we get
XT'= c1 X'T.
Chapter 10: Boundary-Value Problems and Partial Differential Equations
Dividing by c 1 X T, we get
T' x•
(10.13)
c 2 T= X
The left side of Eqn. ( 10.13) is a function of I alone and the right side is a fllllction of x alone. This
implies that the two variables I and x have been separated. The two sides of Equation ( 10.13) are
two separate functions, one solely a function of I and the od1er solely a function of x. Since r and x
are independent of each other, die only way die two sides become equal if they bodi are constant
and equal.
~• =k and x• =k, where k is an arbitrary constant and called I.he separation constant.
c-T X
X" - kX=0
We have to separate the variables in die boundary conditions using Eqn. (10.12).
If X (0) ;t: 0 or X ( L) ;t: 0 then T (r) must be zero for all I and, therefore, u is zero. To avoid this trivial
so lution, we set X (0) = 0 and X(L) = 0.
The boundary value problem in X becomes
X" - kX =0, X (G) = 0 and X(L)=0
Let us solve the bow1dary value problem in X first. Assume k is positive. say k = µ 2 with µ > 0.
Therefore, x• - µ 2 X =0 and its general solution is: X (x) = c,eP' + c1 ,,µ,
To satisfy die condition X (0) = 0 and X (L ) = 0, we need both arbitrary constants c, and c2 equal to
be zero. To avoid this, discard k = µ 2 and instead, try if k = - µ 2 would provide a solution.
With k = - p 2, the equation for X becomes
X (x) = c 2 sinµx.
The condition X (L) = 0 implies that c1 sinµL =0. To avoid the trivial solution X = 0, we set c2 = 1
and sin(µL):a:O.
Chapter 1 O: Boundary- Value Prob lems and Partial Different ial Equations
11
and, X(x)=X. =sin 1C x, n= 1, 2,3, ... is the solution for X.
L
The separation constan1 is
,
k= - µ - = -
,
(L )
l/1C -
lllf ) . ( /11C )
T(t) = a,. cos ( c L t +b. sm c L t where 11 = 1, 2, 3 , ...
1
T~ =a. cosA-,,t+b,, sin A.I where i. =c : and 11 =],2, 3, ...
Combine the solutions of X and T. we obtain a set of solutions for (10. 11) that satisfy the corre-
sponding boundary conditions.
1
u. (x,r) = sin( ~ x ){a,. cosA.r +b. sinA.1 ), 11 = I, 2 , 3 ....
Amy linear combination of the above wiU satisfy Equation (10. J I) and the boundary conditions.
Therefore, by superposition principle. we have an infini1e linear combination as a possible solution
that will satisfy (10.ll), the boundary conditions and the initial conditions.
The second initial condition can be ·used to detennine b•. Differentiate the series in Equation ( 10.14)
term by term with respect to t,
Now sett=0
~ 1=0
= g(x) = ~ . (ll7C
-'-' A,,b.sm
n=I
- x)
L
2 fL . (/11( )
A- b.= LJ
0
0
g(x)sm L x dx, 11=1 ,2,3, . ..
Therefore,
2 fL •
b. = A.L Jo g(x)sm L x d.x
(/11( )
b. = - 2 . (f/1(
J. Lg(x)sm - x )dx, 11 = I , 2, 3, . ..
crm O L
Example 10.4
A string of length, L=2 is stretched along the x-axis with its both ends fastened. The string is setto
vibrate from rest by releasing it from an initial shape given by f (x) and its initial velocity g(x) = 2.
Assume that the s tring vibrates onl y on a fixed plane, and u(x,1) denotes the transverse d isplacement
at time 1;:;: 0 of the point on lhe string at position x. u satisfies the equation
subject to the bow1dary conditions: 11 (0,1) = 0 and" ( L,t) = 0 for all r > 0.
2x if 0SxS0.5
f(x)=
l I if 0 .5 <xS l.5
4 - 2x if i.5< x $2
Using the analytical solution, graph the shape of the string at 0.1 s, 0.2 s, 0.3 s, 0.4 s, 0.5 s, 0.6 s,
0.7 s, 0.8 s, 0.9 sand I s.
Chapter 1 O: Boundary-Value Problems and Partial Differential Equations
Solution
Frnm the equation
we get c =4
2 fl f(x)si m(/11C
a,.= LJ L x ) dx,n=l , 2 , 3, .. .
0
f /(x)s in
a.= 10
2 (lllr x )dx,n=l,2,3, ...
2
r sm
b,.= -L- J,
1
• ( -nn x ) dx, 11=1,2,3, ...
2,m O 2
u(x,r) = I,sin(nn
•=I 2
x)(a. cos(2nm )+ b. sin(2nm ))
We used the first 24 harmonic components to calculate the displacement. Figure I0.2 shows the
displacement of the vibrating string.
1.A ...
1.1 1.1
0.1 0.1
1!
e OA I OA
I I
Ii
OR
.(),3
.0.1 .o.r
-1R -1R
0.1 sec: 0 .2 sec
•1A
OR 0.2 OA 0.6 0.8 1.0 1.2
Potlllon on the sering
... 1.8 1.8 2,0
.u
OR 0.2 OA 0.8 0.8 1.0 1.2
Podion on th~ string
... 1,6 1.8 2,0
1A u
1.1 1,1 OAsec
0 ,1 0 ,1
J•
0
OA
0.0 It OA
o.o
:t0• .0,3 ~
0
-0,3
.0,1 .0,7
•1R •1/J
e.s11e
.1..
0.0 0.2 OA 0.8 0.8 1.0 1.2
Po:dl)on on the string
... u 1.8 2.0
.1.4
0.0 0.2 0A OJI 0.8 1.0 1.2
Position on the string
... u 1.11 2J)
IA IA
1.1
o.s sec t .l sec
l
1.1
0,1 0.1
OA
0.0
i•" 0A
0.0
.0.3 } .();3
0
.0.1 .0.1
,1.0 .11)
.u •IA
0.0 0.2 0.A 0.6 0 .8 1.0 1.2 1.A 1.6 1.8 w 0.0 0.2 0.A 1).8 0.8 1.0 1.2 u 1.8 1.8 2.0
Poa-ftlon on the string Po~ on the thing
u u
1.1
e.7 sec 1.1
0.1 0.1
I 0A
I 0.A
.
ff
~
'5
0.0
.0.3 i
0.0
4.3
i3
.0,1 .0.1
-1.0 .,.o 0.1 sec
·1A
0.0 0.2 0.A 0.8 0.8
"' 1.2 1A u 1.8 2.0
-1A
0.0 0.2 0.A G.8 0.9 1.0 1.2 ,. ... 1.8 2 .0
Potfflon on Ole string PotlU.On on the smg
IA u
1.1 1.1
O.T 0 .7
~ 0A ~ 0A
.."e 0.0
~
.! 0.0
0.
i3• .03 :
i3
.().3
.0,1 -0,7
·1.0
0 .1 ••c .... 1 .0 sec
•IA
0.0 0.2 0.A o.e 0.8 1.0 1.2 u 1.8 1.8 2.0
.....0.0 0.2 0.A 0.6 0.8 1.0 1.2 ,. ... 1.9 2.0
Position on lhe string Poulon on the ttrtng
9. L=2, g(x)=2,c=l/2and
2X if O$ X $ 0.5
f(x)=
lI if 0.5<x~l.5
4 - 2x if 1.5 < X $ 2
2x if O$ X $ 0.5
/(x)= I
l if 0.5<x$1.5
4 - 2x if l.5< x$2
2X if O$ X $ 0.5
f(x)=
l1 if 0.5<x$1.:5
4 - 2x if l.5<x$2
J2x if0Sx$1
/(x)=14 - 2x if l<x$;2
2x if0Sx$1
f(x)= { 4 - 2x if l<x$;2
J U X, (; t)
oo oo
.
- . --
t
X
0 ' I
L
Figure 10.3 Insulated bar with ends kept at zero degree
Let 11(x,1) represent the temperature at point x of the bar at time 1. The ends of the bar are beld at
constanttemperature 0. The initial temperature distribution of the bar is 11 (x,0) = f (x). Find ll(x,1)
for O< x < L , I > 0 where II satisfies the one din1ensional heat equation
011 ? d2 LI
- =C - (I 0. 16)
d/ c)x 2
The boundary conditions are: 11(0,1)=0 and u(L,r) =0 for all r > 0.
The initial condition is: u(x,0) = f (x) for 0 < x < L.
Let us assume that ll(x.r) can be expressed as a product of two functions.
ll (x ,r) = X ( x) T (t) where X ( x) is a function of x alone and T (t) is a function of I alone. Substitute
ll(x,1) = X (x) T(t) in the heat equation.
Therefore, to hold the equality, ~, =k and x• =k, where k is the separation constant. With the
c·T X
separation of variables, we get the following two ordinary differential equations.
In order to avoid trivial solutions, we need the boundary conditions X (0) = 0 and X ( l) = 0. Thus the
boundary value problem in X becomes
k= - µ-= - (
?
L
II n'
)
, 11= 1, 2 , 3, ... and
/l7f
X(x) = X,, =sin L x, 11 = 1, 2, 3, ...
( J0.17)
( /I 7f
11. ( x,t ) =b..e- A•1 sm
•
L x ) , n=l , 2 , 3, .. .
The solution and the given boundary conditions hold for 11 = I, 2, 3, .. _ Therefore, using superposi-
tion principle, we can write
( 10.18)
The coefficient b.. can be obtained utilizing the initial condition. Seti= 0.
Therefore,
2 rl f(x)s .m (111r
b,,= LJ L x ) dx,n=l ,2,3, .. .
0
Chapter 10: Boundary-Value Problems and Partial Differential Equations
Example 10.5
Consider the temperature distribution in a uniform bar of length 2.7T (Figure 10.3) with insulated
lateral surface and no internal sources of heat. Let 11(.r,1) represents the temperature at point x of the
bar at time 1. Both ends of the bar is held at a constant temperature of 0° C. The initial temperature
distribution of the bar is u ( x, 0) = 100° C and c = I.
Using the analyt.ical solution, graph the temperature along the length of the bar at 0.5 s, 1.0 s, 1.5 s,
2.0 s and 2.5 s.
Solution
Let us use the first 24 harmonic components.
11{x,1)= 2).e•J.,
1, sin ( !!.x )
,t:I 2
A. = ( ~
0
J, II= I, 2 , 3, ...
100
90
90
70
-a
$B
60
60
! 40
30
20
10
0
0.00 0.00
Po,ltton on the rod
111 (x) is the steady-state temperature at a distance x from die left end of dle bar shown in Figure I0.3.
The temperature at die ends are: H1 (0) =:,; and u, ( L) = Tr
We subtract u1 (x} from the initial temperature distribution to make the boundary conditions homo-
geneous. Therefore, we solve Equation (10. 16) using die approach we already discussed widi
following boundary and initial conditions.
The boundary conditjons: 11(0,t ) =0 and 11(L,1) = 0 for all 1 >0.
The initial condition: 11(x, 0) = /(x) - 111 (x) for 0 < x < L.
If ,112 (x ,t) is die solution with homogeneous boundary conditions, then die solution widi die nonzero
boundary conditions is
11 (x, t )=u, (x) +112 (x,t)
T, - 7; ~ b -).•, . (111r )
u ( x,t ) = T., + - L x+::; ,.e srn L x .
where
J60x 0~x ~l
/(x)=l 60(2 - x) l~x~2
Chapter 10: Boundary-Value Problems and Partial Differential Equations
J60x O:,x:,l
f(x)=160(2 - .x) J:, x:,2
The boundary conditions are: u(0,1) = 0 and u(L ,t) = 0 for all t > 0.
The initial conditions are: u(x,0) = f (x) and 111 (x, 0) = g (x) for 0:, x :=; L.
Let I, denote the step size in x and k denote the step size in t.
h=L/n
Our objective is to approximate the values
11" = 11 ( ilt, jk ), where 0:, i:, 11 and j ;:: 0
lly represents the value of u at the mesh point (ilt, jk) as shown in Figure 10.5.
U1, j l l
I;
Ui.-1.J u,,j fl,+1.,
lli, j-J
I2
-rt I
k
__L X
I I I
0 x, L
~h--j
Figure 10.5 Mesh points in the xt plane.
Chapter 1 O: Boundary-Value Problems and Partial Differential Equations
The time in discrete form is expressed as 11 = jk and the pos ition along the string in discrete form is
ex.pressed as x 1 = ih.
Let ns find discrete forms of the second derivatives u., and 11,,. From calculus we know that
Therefore, the centered second difference approximation for the second derivatives can be written as
( J0.19)
and
Substituting these centered second difference approximation into the wave equation, we get
( 10.21 )
c2k2
wheres = - ,- .
1i-
The finite difference solution is stable if O< s < l.
Now we have to discretizc the boundary and initial conditions.
U 1,· J·+ 1
...Position...
•
Uj. L, j
•
U 1·+1 ' J.
•
Ui, j-1
Figure 10.6 Mesh points for moving forward in time for the
wave equation
We now use the initial data/and g to obtain the discrete fonn of the second initial co11ditio11. Using
the centered first difference approximation
11(x,1+k) - u(x,1 - k)
111 (x,1 ) "' - ' - - - - ' - - - - - - (10.23)
2k
Setting 1 = 0, we get
u(x,k) -u(x, - k)
g (X ) = 111 ( X, 0 ) "'
2k
11 (x,k) - u(x, - k) =2kg (x)
u(ih.1) - u(ill, - 1)=2kg(ih)
Example 10.6
Determine the displacement of the vibrating string for L = 2, c = I
2x if O~ X ~ 0.5
g(x)=0
J(x)=
l I if O.5<x~l.5
4 - 2x if l.5<x~2
Solution.
Use h = 0.25 and k = 0.1. Therefore, s = 0. I 6 and 11 = 8.
With s=0. 16, expression (10.21) becomes,
(10.27)
Using Equations (10.22) and ( 10.28) related to the bolllldary conditions, we get the following.
110 _0 = 0, 11,.0 = 0.5, ''1.o = l, 113_0 = 1, 11 4 _0 = l, 11;.o = 1, u6 _0 = 1, 111 _0 = 0, 118 _0 = 0
110 _1 =0, u,., =0.5, 11 2., =0.96, 113 _1 =l, 114 .1 = 1, 115 _1 =I, 116 _1 =0.96, it.,_ 1 = 0.5, 118., =0
Now we can use Equation (10.27) to generate results for the remaining mesh points.
110.2 = 0, 111.2 = 0.494, l'2.1 = 0.853, 11"3.2 = 0.994, 114.2 = 1, lls.2 =0.994, 116 .2 = 0.853, 117.2 = 0.494. Llg.1 = 0
=0,
110 _3 111•3 =0.466, 112_3 =0.711, U3.3 =0.966, 114 _3 =0.998, 115 .3 =0.966, 116_3 =0.7] (, 111 __1 =0.466,
!/BJ =0
. = 0,
llo 4 11 1.4 = 0.402, -
U, 4 = 0.57, . = 0.902,
L/34 114 '4 = 0.986, 1154
. = 0.902, 116 .4 = 0.57, It,.4 = 0.402,
118 _. = 0 and so on.
Chapter 10: Boundary-Value Problems and Partial Differential Equations
Table I0. 7 shows the displacement of the vibrating string at various time. Note that the x-axis is
labelled in discrete position steps along the length of the string.
,.,.~-----------------~ ·•~-----------------~
I
J.... I ....
-
.,.,.0.0 .. •• ·-....,.. . . ..
•• . .,.. , .. ,...
,...
-'..J\o •• •• _,..
..,_
.. .. •.. ... .. •••
,.,.
....
uo
.... ....
i ...
I... I....
...
... ...
.....••
,...
.. •• u .. ... ...
_.,
u ...
. . ... .,.,.
...
•• 20
_~
..• .. . .. ...
liff<
,,.. ... 16.0
,., ,.,
....
I
.
...
J I
... 0.0
•• .. .. .._...,.. ... . ...
.... .. 4 ~• .. .. .. .......... ..,, ... uo . . ...
,_,. ,.., ,.,_
....
:..o .."
. ..,
.... ....
I ... l
! 0.00
i ...,
! ....
.... ...
_,,.
•• 10
•• •• •• •••
S•QtNNftll
... . . ... .....
•• ,. •• . .._,.. ...
u tt• .. 16.0
Figure 10.7 Displace ment of the vibrating string using finite difference technique
Chapter 1 O: Boundary-Value Problems and Partial Differential Equations
As shown in the earlier section, the vibration of the string in tbis example can also be calculated
using the analytical technique. Table 10.8 shows the results obtained from the analytical and discrete
techniques side by side for comparison.
1.4------------------~
1,1 ...
0.7
....
l:;i..::::'---------------::::.i
i!s .(1.3
! o.ojL-------------c>.f
I ...
4 .7
-1.0
O.S sec
.u.._- -~- ~0.6- ~0.8- ~1.0- 1.2
~ - 1~A - 1,8- - 1.8r---12.0 0.S.scc.
0.0 0..2 OA ·'.J\·'""•- ~..~ -.~.- ~..~ -.~.- -..~.- ,--..~.- -,~..~- - ,...
!
Position on the string t.1>llfll. . (lt,I
1.4------------------~
1.1 ..
'·"
0.7
...
li
t o.ot------------------1
;!s
0.4
4 ,3
J....~t-------i
_.
4 .7
-1.0
02
sec
.u.._--~-~-~-~-~-~------1
~ ~ M ~
1.8
~ 12
Po~M on th.! string
U 1B IB U .. .. u •• •• no wo 110
c50.
0.4
O.Oj,-=:::---------------:::,,,1
.(),3
I....
•~t-<::--------------,::,,i
4.1
-1.0 ....
.u.._--~-~-~-~-~-~------1
0.0 02 0.4 0.6 OB 1.0 12 1.A 1.11 1B 2.0
Posltion on the string
.. .. 10.o 11.0 14.0 IU
1.4,------------------~
1.1
0,7
2.a sec .....
1
J;:i._--------------------:,1 1
OA
••1c--------------,,;
••
4.7
•l.0
-U +-- - - - ~ - ~ - ~ - ~ - ~ - ~ - ---<
...
0.0 02 O.A 0,$ 0.8 1.0 1.2 1.4 U 1B 2.0 •.,....,...._~,.- -,.---..- -u~ --,..- -,,.
~-~...- --,t,u
Position on the string . , .... Ori
1, 1 , - - - - - - - - - - - - - - - - ~ ·-~ - - - - - -u ..-, - - - - - ~
1,1 2.5 se c
0 ,7
fe OA
I :: .(J,7
.1.0
-ul - - ~ - ~ ~ - ~ ~ - ~ - - ~ - ~ - - l _J
0.0 0.2 OA 0.6 0.8 1.0 1.2
Po.s.Won on th• string
1A 1.S 1.8 2.0 ·l ~ ~
. _.,
,~.-=••-~,=
.-=...~~ tU WI ..
Figure 10.8 Displacement of the vibrating string using analytical and finite difference techniques
The respective shape of the string at various times obtained by using both analytical and finite
difference techniques are almost identical. The results obtained from the finite difference approach
are in good agreement with the results obtained from the analytical technique.
9. L=2, g(x)=2,c=l/2and
l I
4 - 2x
if 0.5 <x:,; 1.5
if 1.5 < X :,; 2
Chapter 1 O: Boundary-Value Prob lems and Partial Different ial Equations
2x if O ~ X ~ 0.5
f(x)=
!I
4 - lx
2x if0~x~l
J(x)= { 4 - 2x if l< x~2
13. L= l, g(x)=sin(n-x),c=land
f(x)=
l2x if OS .t S I
4 - 2.r .if 1<.t· <
_2
The boundary conditions are: u(0, 1) = 0 and 11 (L,r) = 0 for all t > 0.
The initial conditions are: 11(x,O) = f (x) for O< x < L.
Finite difference method can be utilized to approximate the values of the unknown function at dis-
crete intervals. The process begins by dividing the independent variables into a discrete grid struc-
rure. Let us dividex (position) into n parts with a step size of h. Similarly. divider (time) into III parts
wi th a step size of k.
x, = ih, i = 0, I, 2, 3, . .. , 11
r1 = jk, j = 0 , I, 2, 3, ... ,m
Frnm calculus.
lim -u~(x_+
_l_1,~l)~ --2_u~(~x ,_1)~+_1~1(~x_-_h_,t~)
h....O h2
u(x,r + k) - tt (x,t)
111 ( x, T) "' ---'---'---'---'- and
k
At the mesh point (ih,jk) we have lhe following approximations with respect to the first derivative
and the second derivative.
. . ) 11(ilt,jk+k) - 11(ilt,Jk) I ( )
11, (th, ;k "' k "'k 11, _,+1 - 11,.J
I c1
k (" 1.1+1 - u,.1) = h 2 ( ll1+1J - 2u1.1 + u,. 1.1)
c2 k
wlneres= - ,.
Ir
The boundary and initial conditions have to be discretized as well.
To compute u 1.J+ 1 we need the three values 11,. 1.J• u1_1 and u,.,.1 as shown in Figure 4.
Chapter 1 O: Boundary-Value Problems and Partial Differential Equations
U ,,
· J·+ 1
..
Position
...
•
U ·.
I, J
•
U 1·+l. ' J.
Figure 10.9 Mesh points for moving forward in time for the
heat equation
The finite difference approach for heat equation is unstable ifs> 1/2. For stability of the approach
0 < s <S. 1/2.
Example 10.7
A thin bar of length 2 unit is placed in boiling water. After reaching 100° C throughout, the bar is
removed from the boiling water. With the lateral sides kept insulated, s uddenly, at time I = 0, the
ends are immersed in a medium with constant temperature 0° C. Use the fini te difference method to
approximate the solution to d1is problem at 1 = 0.2, 0.4 and 0.6 sec.
Solutio11
Divide the length into IO equal parts and hence h =0.2. Talce a time step of k =0.0 I.
Chapter 10: Boundary-Value Problems and Partial Differential Equations
Boundary conditions:
Initial conditions:
The temperature beyond the initial conditions that satisfy the boundary conditions are calculated in
the foUowing manner.
Figure LO. 10 shows the temperature distribution along the length of the rod calculated using the
finite difference method.
Chapter 1 O: Boundary-Value Problems and Partial Differential Equations
120,~ --------------------~
108
96
84
j 72
!: 36
2A
2 3 4 s g 7 8 9 10
Position ('hl
Figure I 0.11 shows the comparison between the results obtained using the analytical and finite dif-
ference techniques.
120
0.2sec
108
•
84
i eo12
.'
E
I- 48
"'
■ FJnltt Olfftrtne-t ■ Analytktl
2
, • I
• 7
• • 10
Po,ltion(lht
120
0.4 sec
108
96
84
• 72
I 60
48
"'
2A
2 3
• Positions (thl 6 7 8 9 10
,..,
0,6 Se<:
108
e
..
IMS
72
il
!; 60
....
0.
E
"8
36
24
Figure 10.11 Comparison between the results obtained by analytical and finite difference
technique
0~x ~ l
/(.x)=
!
60x
60(2 - x) l~x~2
CHAPTER 11
0 TIMIZ Tl N
Optimization techniques are utilized to make decisions in many areas starting from economics to
engineering. The objective of optimization is to make the best decision under given circumstances.
111 most cases the principle objective of optimization is to minimize cost. Starting from its initial
application to design problems, optimization techniques have spread into other areas like invest-
ment, transportation, business, management, pub lic services, operations research to name a few.
The advent of fast and powerful computers have made it possible to solve complex optimization
problems with relative ease. 111 this chapter we will be dealing with optimization problems that can
be expressed in quantitative manner.
Am optimization problem has two main components; an objective function and a set of constraints.
The objective function is a mathematical model that relates the underlying variables associated with
the product or the process. The constraints are mathematical expressions that define the relationship
between certain variables and, in many cases, define the limit imposed on certain variables.
111 this chapter, some foundational concepts related to optimization are discussed first followed by
unconstrained optimization. Constrained optimization techniques are discussed in the later part of
this chapter.
The expression la+ (1 - 1 )b, 0:,; A:,; 1 is called a convex combination of the points a and b.
In a generalized way, if xl' x 2 ,x3 , _ •. , x. arc points in a convex set X, then a point x of the form
x = l,x, + A.iX2 + · ·· + J..x. where A.1 +Ai+···+?... = I and A1 ~ 0, i = L, 2, .... n is called the convex
combination of x 1 ,x2 ,x3 , ••• ,x. and also belongs in X.
at points other than a and b may actually be greater than f(a) and smaller than f(b). Figure J 1.2
shows a function J(x) with its relative maximum and minimum .
.fi:x)
0 X
The value of a function at a relative maximum or at a relative minimum is called an extreme value
of the function. The value of x where the function has either a minimum or a maximum is called a
critical value.
(11.1 )
( 11.4)
Chapter 11: Optimization
clf(x 0)
-'---'--"-'- ~0. (11.5}
dx
The results ( I 1.4) and (11.5) together lead to lhe conclusion lhat
(11.6)
f(xo+h) - f(x 0 ) ~O
h>O (11.7)
Ii
( l l.8)
Therefore, when we take limit as It ➔ 0 and foUow the similar arguments I.bat we did for the relative
maximum, we conclude lhat for a relative minimum,
df(x0 )
0. ( 11.9}
dx
A graphical explanation can be given for the necessary condition for a maximum as shown in
Figure 11.3. The slope, f'(x) of this function is shown at several places on the curve with arrow
marked Line segments. f' (x) is posi.tive on Lhe left-hand side of lhe maximum point and negative on
_/{x)
0 X
the right-hand side of the maximlllll1 poim. Since J' (x) is continuous, a transition from positive to
negative can only happen if f' (x) becomes zero in betv,een. As shown in the figure, f' ( x) is zero at
x0 indicating that the function f (x) does not increase beyond x 0 • As shown in the figure, a similar
explanation with d1e signs reversed can be given for a minimum poinL
The points where d1e first derivative of a function is zero are called stationary points. The stationary
points are the candidates for relative maximum, minimum and saddle points.
If J(x) has a relative maximum at x 0 , then we know from the necessary condition d1at f'(x)=O.
Therefore, Equation (11.10) can be rewritten as
( 11.11)
( 11.12)
Since /,2 is always positive, the only way the term /i2 /"[ 0x0 + (l - 0)(x0 +It)] can be less than zero
2
iff"[0x0 +( l - 8)(x0 +!i)]<O.
It foUows from d1e continuity of f ' (x) that if f"[0x 0 +(1 - 0)( x 0 + h}]<O, ilien J'(x0 )<O.
Therefore, we conclude mat if f'(.v 0 ) < 0 when f'(x0 ) = O, f (x0 ) is a maximwn.
If f (x0 ) is a minimum poim, ilien
( 11.13}
Following a parallel argument that if f'(x 0 )> 0 when f'(x 0 ) = 0, f (x0 ) is a minimum.
A graphical explanation for die second derivative condition can be given wid1 respect to Figure 11.3.
f' (x) is positive on the left-hand side of the maxin1wn point and negative on the right-hand side of
the maximum point. This means d1at for a maximum, f'(x) decreases as we move from die left side
of the maximum point to the right side of die maximum point. Decrease of f'(x) means its derivative
wid1 respect to xis negative, i.e., f'(x) < 0 in die neighborhood of x 0 including at x 0 •
However, it is possible iliat at x 0 , bod1 the first derivative and die second derivative vanish. We must
then examine the higher order derivatives. Let us start with the following theorem.
Chapter 11: Optimization
Theorem: Assume that / (x) and .its first II derivatives are continuous. Then / (x) has a relative
maximum or minimum at x 0 if and only if II is even, where n is the order of the first non-vanishing
derivative at Xo, The function has a maximum at Xo if f" (xo) < 0 and a minimum if/" (xo) > 0.
Proof
Since f(x) is continuously differentiable and its 11th derivative exists on the interval [x0 , x 0 +h], we
can write the following using Taylor's theorem.
Let us assume that the first 11 - I derivatives of/ (x) at x 0 vanish, i.e.•
Therefore.
( l l. 14)
We conclude from Equation ( 11.14) that the sign of {f(x0 +!,) - f(x0 )} is the same as the sign of
h" J"[0x0 + (l- 0)(x0 + h)} Since/" (x) is continuous,/"[0x0 + (1 - 6) (x0 + h)] will have same sign
11!
as f" (x0 ). This leads to the conclusion that {/(x0 + h)- f (x0 )} will have the same sign as f" (x0 ) if
11 is even. Because II being even is the only situation where the sign olf !!:... J"[8x0 + (1 - 8)(x., +h)] is
11!
the same as the sign of J"[0x0 +(l - 0)(x0 +h )]. Therefore, when II is even,{/ ( x0 +h ) - f (x0 )} is
positive when /" (x0 ) is positive an.d {/(x0 +/,)- /(x0 )} is negative when/" (x0 ) is negative. This
leads to the conclusion that/ (x0 ) will be a minimum if/" (x0 ) is positive and will be a maxinmm
if r (x.,) is negative.
Let us consider the following function.
. hing d envauve
Tl1e first non-vams . . 1s. -d• Yi,- . 111s
. even and - Yi 1s
d• - . . theretiore, f ( x ) Iias a nun-
. pos1t1ve, .
4
dx dx
imum at x = 2 Figure 11.4 shows the plot of y,.
16.0
13.7
11.3
9.0
6.7
"='-
,I:;.
';::;; •.3
2.0
.0.3
-2.7
~.o
~.00 ·1.00 0.00 1.00 2.00 3.00 4.00
.>:
' 3 •
dy1 =-4(x - 3}3; d-y_,2 = -12(x - 3)2; d ):1 = - 24(x - 3); d ~2 = - 24
dx dx- dx dx
The first non-vanishing derivative is d' J~i . 11 is even and d' )~2 is negative, therefore, J(x) has a
dx dx
maximum at x = 3. Figure I 1.5 shows the plot of y1 .
Chapter 11: Optimization
6.0
-3.7
-13.3
-23.0
-32.7
v
'.::; ◄2.3
,62.0
-61 .7
.71,3
-t11.0
-1.00 -ll.13 0.75 1,63 uo 3..38 4..25 5.13 6 .00
Consider the following function where the first non-vanishing derivative is odd.
3
y3 = J(x) =x3 - 6x 2 + 12x - 8= (x - 2)
100.0 ·
77.8
65.6
33.3
11.1
~
,::::; ·11.1
-33.3
,65.6
-77.8
-100.0
-8.00 ◄,.oo -2.00 0.00 2.00 8.00
Figure 11 .6 Plot of y 3
Chapter 11: Optimization
It ,can be noticed that in Figure 11 .6 the slope on the left of the poiI11t of inflection is positive, then
at the point of inflection the slope becomes zero and then on the right of the point of inflection the
slope is again positive. This is the characteristic of a point of inflection that the slope around it does
not change sign. The point of inflection (saddJe point) is a stationary point that is neither a relative
maximum nor a relative minimum.
Example 11 .1
Find the global maximum off (x) in [ 0, 2.5).
Solution
f'(x)=x 3 - 6x 2 + I lx - 6
( 11.15)
the second derivative is positive in [ a , b]. It should be mentioned at this point that the sum of two
or more convex functions is also a convex function.
Theorem: Let f(x) be a convex function over a closed interval, a sx $b. Then any relative mini-
mum of f(x) in this interval is also the absolute or global minimum of f(x) over the interval.
The global maximum of a convex function J(x) over a closed interval, a$x $ b will be either J(a)
or f ( b) or both.
A concave fw1ction /(.r) is a continuous function over a closed interval a $x $b that satisfies the
condition that
!
.f{x) ·····J--···· L
j.• ...
I
L r- .L..
! .• -
••• j •••••••••
! '
!~········1··················l· ~ ~
X
0
Figure 11 .8 A concave function
Theorem: Let f(x) be a concave function over a closed interval, as x $ b. Then any relative maxi-
mum of f(x) in this interval is also the absolute or global maximum of f(x) over die interval.
The global minimum of a concave function f(x) over a closed interval, a$ x $ b will be either f(a)
or f ( b) or bod1.
Chapter 11: Optimization
./ '
,, 0 XO x•,, I
x,
• x~ X i- I I
II I I I I I
•x• x'i I
0 x.
Figure 11.9 Subintervals for exhaustive search
Chapter 11: Optimization
f(xi) =f(O)=O
J( xn = f (6) = 0.0086
f(x~) = /(12)=0.0127
J (xf) = J(l&)= 0.01 2s
f (xn = /(24)= 0.0104
f (x!) = /(12)=0.0127
f (x~) =/(IS)= 0.013
J (x!) = /(! 8) = 0.0125
After tlle second iteration, the current maximum is f(x!) = /(15) = 0.013. If further improvement is
necessary, we will carry out a tllird iteration in [12,18] by making the subintervals even smaller than
Lhe second iteration. The iterations will stop when the absolute difference between tlle successive
maximum will be less than or equal to a given tolerance.
Chapter 11: Optimization
The above sequence gives the Fibonacci numbers as: l, I, 2, 3, 5, 8, 13, 2 1 ....
We assume a unimodal function f ( x) in [a , b].
In the first trial. two boundaries are determined such that they both are same distance away from the
two ends of the interval. Once the number of trials II is known, the distance is calculated as
d' =(Fn-1)d
F o
"
where
a=0, b=300
d., =b- a=300- 0=300
Since f (x3 ) > f (x,), the discarded zone is [ x,, x 2 ] = [114.286, 185.7 [4]
The new interval is [ a, x,] = (0, 114.286)
The location of the new boundary .t:4 should be such that its distance from the endpoint a should be
same as the distance between x 3 and x,.
Therefore, x 4 =a+(x, - x3 )= 0+(114.286- 71.429)=42.857
Since f ( x,) > f ( x3 ), the discarded zone is [x3 , x,]=[7 1.429, ll4.286]
The new interval is [ a, x 3 ] = [ 0, 7 i.429].
Amdsoon.
The maximum is 0.013 located at .x-7 = 14.286.
Problem Set 11 .3
For the following unimodal functions in their respective intervals, find the maximum (minimum)
utilizing the Exhaustive and F ibonacci search methods.
?
L /(x)= 2
x- in [-9,9]
X - 89
125
2. /(x)=<+ in[ -6,6]
x- + 225
4. /(x) = x',++512
X
1250 in [-6, 6]
5. f(x)= , X in[0,500]
x-+512
625
6 . f (x) 2
x in [-500. 0]
X +J024
In a similar manner a function f( x) is concave over some convex set X in R" if for any two points
x, and x2 in X and for all 0, 0 ~ e ~] the inequality (I 1.18) holds.
(I 1.18)
Let/ ( x) is a continuous function with continuous first- and second-order partial derivatives over an
open convex set X in R", then utilizing Taylor's Theorem, we can state that for any two points x, and
x2 = x, + h in X. there exists a 0, 0 ~ e ~ I such that
(11.19)
vi -(aJ
- ax,
a1 ...
dX2
a1JT
ax,,
H is the Hessian matrix off (x) and is defined as an 11x11 matrix of second-order partial derivatives
off (x).
a21 a12
llf
ax: ax, ax2 ax,ax.
·,pf a21 ,Pf
H = ilx2 ih1 ax; ilx,- axn
Assume that a minimum or maximum occurs at x = x0• For single variable cases we used the condi-
tion that tbe first-order dcrivaLive be zero at tbe point of a maximum or minimum. We can utilize this
condition for multivariable cases as well. However, instead of just one first-order derivative, we will
have multiple first-order partial derivative for multivariable cases.
aJ( xo)
0 i = ], 2, 3, .... n
ax,
- T
Therefore, Vf( x0 ) h =0
( I I.20)
Similar to the single variable case in Equation (11.1 4), the sign of {f(x0 + h) - /(x0 )} depends
on tbe sign of hTH[ 8 x0 + (J - 8)(x0 + h )] b. Again due to the continuity of the second-order par-
tial derivatives, hTH [x0 ]h will have the same sign as hTH[0 x 0 +(1 - 8)(x0 +b )] h. Therefore,
{/ (x0 + h) - f ( x0 )} wil l be +ive if b TH ( x0 Jb is +ive and -ive if hTH [ x0 ) h is -ive.
Example 11.2
Determine the maximum of
Solution
l[,l
of( x)
ax,
[VJ( x)r =
aJ( x) [-,,.• 1•
= -6~2 +24 = 0
ax?
lJJ(x )
3
2x 0
ax3
Chapter 11: Optimization
l
ax1ax3 dX1l
-8 o o
H (x0 )= 0 -6 0
[ 0 0 -2
yrH(x0 ) y =- 8y~ - 6yi - 2yJ which is clearly less than zero for any YT = [ y, y2 y3 ] provided
Example 11 .3
Determine the minimum of
f (x)= f (x,, x 2 ,.l'3 )=2x~ +3x; +4x: - 8x, - 12x2 - 24x3 + 11 0
Solutio11
ll l
at(x)
i)x,
c)J(x) 4x, -- 12
8 O
= 6x1 = 0
dX2 [ 8x - 24
3
0
i>f (x)
i)x3
Chapter 11: Optimization
iJ1 f (x) 4
i'P f (x) =O if /(x) 0
i)x: i_lx, i_lx2 dX1dXl
·,)1 f (x) 6 di J(x ) 0 i)2 f (x)
8
ax~ dX2dXl clx;
l
4 0 0
n(.,)-[ 0 6 0
0 0 8
yrH(x0 )y = 4i +6y: +8yJ which is clearly greater than zero for any YT= [ Y, Y2 y3 ] provided
y '# 0. Therefore, x! = [ 2 2 3 ] is a minimum point.
Note that the Hessian matrix in this example is a diagonal matrix with all positive elements. A diag-
onal matrix with aJJ positive cleme'llls is a positive definite matrix. A symmetric matrix is positive
definite if its principle determinants are aJJ positive and positive semidefinite if they arc alJ nonnega-
tive. In a more concise form we can state that a symmetric matrix M is positive definite if yTMy > 0
for alJ y #! 0, and positive semidefinite if yTMy ~ 0 for all y.
Figure 11. IO shows the grid structrure in a two dimensional case. The starting point is labeled as
A. The 3 2 - 1 points surrounding A arc numbered I to 8. If the contours are in the direction of the
,
I If
' '\
/ I
.
I I I I'\. ! \
I ll - ~ '\ ,- 1\
._ f-
- -- -BJ
~
g
I
~ \
\
\ \
\
\
\ 'f
~
._ -
I in t- )_ I
'
- 'SI' ' ~
\ ·1- \
ct
"'
~
~
©\
......
,._,__
I'...
I
I
I
I /
,J
'L J
,
-....
' ' \ '\ 'i- '\!- " '\..,
-~,y
I
I ., ~
,, I
lL ~ .: -<" ./
~ l \• ,_ j '- t-.... I ~
/ ~
7 ~ 6
Figure 11 .1O
' i-... 1'-..
Two-dimensional grid search
I
Chapter 11: Optimization
function increasing towards B, then if we are maximizing, we would choose point 3 as our next
starting poim. Successive choices arc shown as circled points. When we come close to the point B
we would have to reduce the grid size in order to get as close as desired to the maximal point.
x 1 = x0 + il,a,
where a, = [1, 0, 0, . ... 0 rand il, is a scalar such that f (x0 + il,a,) is maximized (minimized).
Similarly point x, is detennined by performing a maximization (minimization) wid1 respect to the
kth variable.
x, = x,_, + l,a,
where a, = [ 0, 0, .. ., 1, . .. , 0 r and 1, is a scalar such that f (x._1 + 1,a,) is maximized (minimized).
The steps are repeated until ll,I for each variable becomes less than a tolerance.
Figure 11.11 shows a univariate search approach for a two-dimensional case. The univariate approach
works well for functions that have Less interaction among the variables.
x,
Figure 11 .11 A univariate search in a two-dimensional case
Chapter 11 : Optimization
Example 11.4
Minimize f (x,, x1 ) =4x, + 7x2 +x,x2 - x~ - Xi
Solutio11
Let us start at(x1 ,x2 )=(7, 7).
Fix x 2 = 7 and solve the problem Min f (x,, 7) with respect to x,.
The derivative off (x) with respect to a direction v can be expressed in terms of partial derivatives
in the following manner:
lvl =l ( 11.21)
maximize td
J=I
f ( Xo) VJ
dX1
•
slibjectto g (v) = I, vJ = L
J=I
(I 1.21)
aF =1 -L," Vj, =O
- ( I 1.24)
ail J=I
1- • _ I [cJf(xo)]l =0 ( I 1.26)
L,
}=I
4A1 ax J
2
A =¾IVJ(x0 }i2 {I 1.27)
( 11.29)
The plus sign is for the rate of maximum increase off (x) and the minus sign is for the rate of max-
imum decrease.
Example 11.S
Minimize f(x.,x 1 )=(l.Sx, - .r2 )? +(x1 - 3}2 + 7
Solution
The gradient is:
( 11.30)
Let us start our descent from a point P0 = (6, 7). At P0• f (x 1, x2 ) = 27. The gradient vector of
f{x,,x 1 ) at P0 is:
Chapter 11: Optimization
The unit grailient vector, v0 would be v0 = 0.832x1 +0.555x2 • Since the objective is to minimize, we
have to move in the opposite direction of the unit gradient vector.
Vector -v O extends one unit ilistance from the point P0 (Figure l l. 12) in the direction of steepest
dc:scenl. Therefore, we should move in the direction of -v0 • The question, however, is how many
nwnber of units in the ilirection of- vO? Because, with too many s teps we may surpass the minimum.
Let us take an arbitrary number of U!Jlits in the direction of -v0, say IO units. This wiU place us at the
point P, as shown in Figure l l.12.
At P,. f(x 1,x2 )=33.735. It is obvious d1at by moving from Fo to P, we have moved too far. Instead
of decreasing, we actually increased the value of the fw1ction. Therefore, we have to find a way to
correct our course. Which we can do by determining the gradient vector of .f(x,, x1 ) at P,.
..
.... . u
x,
.. •
Since in our previous step we have passed the minimum, we will take a shorter step this time along
the direction of -v 1, say 2 units. We will move from P, to a new point P2 .
With our most recent move. the value of the function bas decreased compared to the previous step.
We will continue wid1 the steps until we reach the minimum. However, we need some technique to
determine how far to move at each step without moving too far from the minimum.
Example 11 .6
Solutio11
The gradient of f(x,,x 1 ) is:
ilf
Vf(x" x1 )=
ax,
"c}f
il.x1
=[
4.Sx, - 3x2
- 3x1 +4X1 - 6 ]
The gradient vector off (xi, x 1 ) at Po= (6, 7) is:
The partial derivative of f(x 1 , x1 ) at P0 =(6, 7) iudicates that the function, f(x, , x1 ) is increasing
at a rate of 6 units per unit increase in x 1 and increasing at a rate of 4 units per unit increase in x 1 •
Therefore, in order to move away from P0 = (6,7) it would be advantageous for us to decrease
both x 1 and x 1 . Since we are permitted to change only one variable, we will select die variable that
Chapter 11: Optim ization
will produce a greater contribution towards the minimization of f(x,.x 2 ). At poim P0 =(6, 7), we
will have a greater decrease in / (x,, x 2 ) with a unit decrease in x, than with a unit decrease in x2 •
Therefore, hold x 2 at 7 and increase x, by some increment. Next, determine by how much should
we decrease x,?
Let us decrease x, by subtracting an increment of r. The oew value for f (x,, x 1 ) will be
We will select t such that it causes the expression (I 1.31 ) to be the minimwn. At 1 = 1.333 the expres-
sion (I I.3 I) becomes the minimum. Therefore, our new point P, is
P, =(6- t, 7)=(4.667, 7)
'iJJ
ax,
V, =
'iJJ =[ ~]
dX2
The partial derivative of f(x,,x 2 ) at P, =(4.667, 7) indicates that the function, f(x,,x 2 ) remains
unchanged with respect to x, but is increasing at a rate of 8 units per unit increase in x 2 and. We,
therefore, decrease x 2 by I io the next move. The new value for f (x,. x 2 ) will be
We will select I such that it causes the expression ( 11.32) to be the maximum. At 1 = 2 the expression
(I 1.32) becomes the minimum. Therefore, our oew point P2 is
P1 =(4.667, 7 - 2)=(4.667,5)
We can continue to find new points in this fashion. Each successive iteration will yield less improve-
ment in the value of f (x,, x 2 ) and we can stop when the improvement is less than or equal to a
pre-specified tolerance.
( I 1.33)
Chapter 11: Optimization
where
vl•>is a wlit vector in the direction of the steepest ascent and
VJ(x1'>) is the gradient vector off (x) at xl•J_
In search of the maximum, therefore, the transition from x<•Jto x<>+•J will be as following:
(I 1.34)
df ( x<•> +iv<•>)
0 ( I 1.35)
dl
Let us assume that / (x) is a quadratic function. The hessian for a quadratic function remain
unchanged. By utilizing Taylor"s expansion, f (x), therefore, can be written as:
( I 1.36)
( 11.37)
( I 1.38)
For a quadratic function, elements of the Hessian matrix, H are either constant or zero.
The gradient of f (x) is
V/(x)= b+Hx
Therefore,
( 11.40)
Introducing x <t+iJ -xl•I for ,1. t•Jv <•J im Equation (11 .4 I) we get
The Hess.ian matrix, H is a symmetric matrix. Therefore, HT= H. Amd, therefore we can write
Ta.king transpose,
Eq uation ( I 1.42) indicates that the gradien t at x<•+i) is orthogonal to the previous search
direction, vl'l.
Example 11.7
Chapter 11: Optimization
Solution
Iteration l
We start from xt J
0
=[ ~ ].
Vf(x(Ol )=[ ~.5x 1 - 3x1 ]=[ 6 ]
- 3.t 1 +4x~ - 6 4
H=[ ~~ -! ]
x(1) +
=x<o> A-(Olv(o) =[ 6
7
]+ 4 _573 [ 0.832 ]
0.555
=[ 2. I95 ]
4.463
A(Ol is negative, meaning we are moving towards the minimizi ng point by going in the opposite
direction of the gradient vector.
After the first iteration the value of the function is I0.5 I 2.
Iteration 2
Um.t vector ID
. th e directton
. o fthe grawent
..1: •
1s V'11) = [-0.555]
_ •
0 832
H=[ - 3 4.5 - 3 ]
4
Chapter 11: Optimization
A.(I) =([ - 3.512 ]T[ -0.555 ])([ -0.555 ]T[ 4.5 - 3 J[ - 0.555 ])-I=-0.9 [5
5.268 0.832 0.832 -3 4 0.832
Problem Set 11 .5
Utilizing (a) multivariate grid search, (b) univariate search method, (c) steepest ascent (descent)
- one variable at a time and (d) steepest ascent (descent) - multiple variable at a time find the maxi-
mum (minimum) of the following functions.
1. f (x,, xi) =(x, - 3x2 }2 + (2x, - 5}2 + 13, 0 ~x, ~ IO and O~x2 ~10
2 2
2. /(x1 , x2 ) =(2x, - 3x2 ) + (4.:r2 - 7) - 5, - 5 ~x, ~5 and - 5 ~x2 ~5
Example 11.8
• •
llllillJJllZe
• 2
;: = 5x1 + 3x 22
subject to x , + 2x 2 = 16
Solution.
First, fonn the Lagrangian function as:
oF(x, A)
( I 1.48)
ax,
(1 1.49)
_a F_('--x_
,A.c...) - 16 - x - 2x =0 ( 11.50)
dA. ' 2
48 160
X = -23 X =-
• I ? 23
Inequality Constraints
Many optimization problems come with inequality constraints (often referred to as soft co,mrai111s).
The general approach is to convert all inequality constraints to equality constraints and fonn a
Lagrangian function and follow the same technique as discussed earlier.
Chapter 11: Optimization
maximize J(x,.~)
subject to g(x,. x 2 ) ~ 0
Convert the inequality constraint to an equality constraint by introducing a new variable, s (often
referred to as slack vari.able) in the following manner:
The variable s is squared to ensure that s2is always positive regardless the value of s. With this
modification, the equivalent problem becomes:
minimize J(x1 , x2 )
subject to g(x,.x 2 )- s2 =0
We take partial derivatives of the Lagrangian function and equate them to zero.
-
aF -_-
at- 11,-
, i)g -_ 0 ( 11.51)
ax, ax, ax,
( 11.52)
( 11.53)
( 11.54)
Condition ( 11.54) states that if 2,ls = 0, either A or s or both equal to zero. Ifs is zero then from
condition ( 11.53) we can write that g (x, , xi)= 0.
Multiply both sides of condition ( 13.d) bys. We get
AS1 =0
( 11.55)
The essential conditions, then are (I 1.51), (I 1.52), (I 1.55) and the original inequaliry constraint.
These conditions are known as Kuhn-Tucker conditions for the optimization of a function subject to
an inequality constraint.
Chapter 11: Optimization
C. ,!,g(x,.x2 )=0
d. g ( Xi, X2 ) ;:: 0
Example 11.9
minimize f(x,, x"2)=2x, +x,x1 +3x2
subject to x~ + x 1 ;:: 3
Solutio11
The inequality constraint can be rewritten as:
a. 2+x1 - 2Ax1 =0
b. 3+x1 - A.=0
First, we will assume that the constraint will be satisfied. In that case we will then set ,l = 0 and solve
(a) and (b) for x 1 and x 2• We get x, = - 3 x 1 = - 2. We check 10 see if the constraint is satisfied. In
!his case lhe constraint is satisfied and, therefore, x1 =- 3, x2 =- 2 will be our minimum point. The
constrained minimum of the function is --6.
Example 11.10
minimize f(x,, -~) = 2x1 +x1x 2 +3-½
subject to x, + x 1 ;:: 3
Solution.
The inequality constraint can be rewritten as:
g(x,,x2 )=x1 +.t'1; - 3;;::0
Chapter 11: Optimization
c. it(x, +x1 - 3) =0
Like we did in Example 11 .5, first, we will assume that the constraint wW be satisfied. In that
case we wiU then set it= 0 and solve (a) and (b) for x 1 and x2 • We get x, = - 3, x 1 = - 2. With d1ese
vaJues the constraint is not satisfied. Therefore we now set the inequality constraint as an equality
constraim and set A-:/! 0. In that case we wW have to solve (a). (b) and {c) for x,, x 1 and ,l. We get
x, = I, x 1 = 2, it= 4. T he constrained minimum of dle function is I0.