Vous êtes sur la page 1sur 120

FOREWORD

Numerical Method: The Easy Way is an innovative


book that introduces topics in Numerical Methods in the
simplest way.
The main objective is to make the learning of
Numerical Methods easier. We have developed features to
make this book as student-friendly as possible. These
include the use of introduction in every topic and multiple
comprehensive examples. We also keep our explanations
straightforward and oriented practically.
Exercises and problems with relevant applications
have been included into the exercise sets of every end of
the topic.
The authors and editors are grateful to our
colleagues and professors in the academe for their
constructive criticism and suggestions.

The Authors

CHAPTER

SOLUTIONS TO
LINEAR

EQUATIONS
A linear equation is an algebraic equation in which
each term is either a constant or the product of a constant
and (the first power of) a single variable.
Linear equations can have one or more variables.
Linear equations occur abundantly in most subareas
of mathematics and especially in applied mathematics.
While they arise quite naturally when modeling many
phenomena, they are particularly useful since many nonlinear equations may be reduced to linear equations by
assuming that quantities of interest vary to only a small
extent from some "background" state. Linear equations do
not include exponents.
A common form of a linear equation in the two
variables x and y is

where m and b designate constants (parameters).


The origin of the name "linear" comes from the fact that
the set of solutions of such an equation forms a straight
line in the plane. In this particular equation, the
constant m determines the slope or gradient of that line
and the constant term b determines the point at which the
line crosses the y-axis, otherwise known as the y-intercept.
Since terms of linear equations cannot contain
products of distinct or equal variables, nor any power
(other than 1) or other function of a variable, equations
involving terms such as xy, x2, y1/3, and sin(x) are nonlinear.

General Form:
Standard Form:

Matrix form:
Using the order of the standard form

one can rewrite the equation in matrix form:


[

][ ]

[ ]

Further, this representation extends to systems of


linear equations.

Becomes
[

][ ]

Two Types of Methods


Numerical methods for solving linear systems of
equations can generally be divided into two classes:
1.

2.

Direct methods In the absence of round off error


such methods would yield the exact solution
within a finite number of steps.
Iterative methods These are methods that are
useful for problems involving special, very large
matrices.

1-1 INVERSE OF A MATRIX


Inverse Matrix Method
Inverse Matrix Method is one type of
method in solving for solutions to linear equations.
In this method we follow the formula:
Inv (A) A x = inv (A) C
x = inv(A) C

A.

Elementary Row Operations


Given: A = [

1.

Interchange
Example:

A=[

2.

Multiplication by a Scalar Factor

Example:

A=[

3.

Addition of Rows

Example:

A=[

]
]

ss=s[

B.

Row Echelon Form

Example:

a.

The first leading non-zero coefficient


is 1

b.

C.

The leading coefficient is not in the


same level

Reduced Row Echelon Form

Example:

a.

All numbers should be zero in a column


with a leading coefficient
INVERSE OF A MATRIX
AA-1 = A-1A = I

Examples:

1.

A=[

USING ANALYTICAL METHOD:

adjoint ( A)
inv(A) = det( A )
T
adj(A)= [ cof ( A ) ]

adj(A) = [

det(A) = (2)(6) (5)(4) = -8

inv(A) =

inv(A) = [

USING ELEMENTARY ROW OPERATIONS:


A=[

|]

R1 / 2

=[

|]

=[

|]

=[

=[

R2 - 4 R 1
R2 /-4
R1 2.5R2

|]

|]

Therefore,
inv(A) = [

2.

B =[

USING ANALYTICAL METHOD:

inv(B) =

adjoint (B)
det(B)

adj(B) = [ cof (B) ]T

8
4
adj(B) =
8
4
7

2 6

0
0

5 0
3 0

0
0

5 0
3 0

2 6

5 8
3 4

5 8
3 4
2 7

48 (30) 19

0
(4)
= 0

24 (18) 13

0
24
48
30
0
18
adj(B) =

19 4 13
det(B) = [(-3)(7)(0) + (4)(6)(5) + (0)(-2)(8)] [(0)(7)(5) + (-3)(6)(8) + (4)(-2)(0)]
det(B) = -24

0
24
48
30
0
18

19 4 13
inv(B) =
24

0
1
2

0
.75
inv(B) = 1.25

0.7916 0.1667 0.5416


USING ELEMENTARY ROW OPERATIONS:

B =[

R1 /-3

|
|
[

R2 x 3/13
]

R3 + 4/3R2

|
|
[

R2 + 2R1
R3 - 5R1

|
|
[

]
|
|

R2 18/13R3

R1 + 4/3R2

|
|
[
[

R3 x 13/24

]
|

Therefore,

0
1
2

0
.75
inv(B) = 1.25

0.7916 0.1667 0.5416


I.

Solved Examples
INVERSE MATRIX METHOD
inv (A) Ax = inv (A) C

1.

Solve the given system of linear equation


using inverse matrix method

Solution:
[

][ ]

A x =
For inv(A)

|]
|

|]

[
[
X=[

|]

|]

|] (inverse of A)
][

X= [ ]

2.

Solve the given system of linear equation


using inverse matrix method

Solution:
[

] [ ]

[ ]

A
x = C
Using the elementary row operations to get
the inverse of A, we will arrive at:
Inv(A) = [

x=

inv(A)

x=[
x=[

II.

1.

C
] [ ]

Exercises
Solve for the inverse of the following matrices:
C=

3
9

5 2 1
8 5 2
6 3 5

1 3 4

2.

D=

3.

E=

5
8

9 7 2
5 2 4
7 3 8

2 1 5

4
8

7 9 2
5 2 3
7 8 2

4 7 9

Solve using inverse matrix method:


4.

5.
6

1-2 GAUSSIAN ELIMINATION


I.

Introduction

In linear algebra, Gaussian elimination (also


known as row reduction) is an algorithm for
solving systems of linear equations. It is usually
understood as a sequence of operations
performed
on
the
associated matrix of
coefficients. This method can also be used to find
the rank of
a
matrix,
to
calculate
the determinant of a matrix, and to calculate the
inverse of an invertible square matrix. The method
is named after Carl Friedrich Gauss, although it was
known to Chinese mathematicians as early as 179
AD.
To perform row reduction on a matrix,
one uses a sequence of elementary row operations
to modify the matrix until the lower left-hand
corner of the matrix is filled with zeros, as much as
possible. There are three types of elementary row
operations: 1) Swapping two rows, 2) Multiplying a
row by a non-zero number, 3) Adding a multiple of
one row to another row. Using these operations, a
matrix can always be transformed into an upper
triangular matrix, and in fact one that is in row
echelon form. Once all of the leading coefficients
(the left-most non-zero entry in each row) are 1,
and in every column containing a leading

coefficient has zeros elsewhere, the matrix is said


to be in reduced row echelon form. This final form
is unique; in other words, it is independent of the
sequence of row operations used. For example, in
the following sequence of row operations (where
multiple elementary operations might be done at
each step), the third and fourth matrices are the
ones in row echelon form, and the final matrix is
the unique reduced row echelon form.

II.

Solved Examples
1.

Use Gaussian elimination to solve the system


of linear equations
x1 + 5x2 = 7
2x1 7x2 = 5.
Solution:
x1 + 5x2 = 7
2x1 7x2 = 5
Add twice Row 1
to Row 2.
x1 + 5x2 = 7
3x2= 9
Multiply Row 2 by 1/3.
x1 + 5x2 = 7
x2 = 3

Add 5 times Row 2 to Row


x1 = 8
x2 = 3
2. Use Gaussian elimination to solve the system
of linear equations
2x2 + x3 = 8
x1 2x2 3x3 = 0
x1 + x2 + 2x3 = 3
Solution:
2x2 + x3 = 8
x1 2x2 3x3 = 0
x1 + x2 + 2x3 = 3
Swap Row 1 and Row 2.
x1 2x2 3x3 = 0
2x2 + x3 = 8
x1 + x2 + 2x3 = 3
Add Row 1 to Row 3.
x1 2x2 3x3 = 0
2x2 + x3 = 8
x2 x 3 = 3
Swap Row 2 and Row 3.
x1 2x2 3x3 = 0
x2 x3 = 3
2x2 + x3 = 8
Add twice Row 2 to Row 3.
x1 2x2 3x3 = 0
x2 x3 = 3

x3 = 2
Add 1 times Row 3 to Row2.
Add 3 times Row 3 to Row 1.

x1 2x2 = 6
x 2= 5
x3 = -2

Add 2 times Row 2 toRow1.


x1 = -4
x2 = 5
x3= 2

Multiply Rows 2 and 3 by1.


x1 = -4
x2= 5
x3 = 2
x1 = -4
x2 = -5
x3 = 2

3.

Perform Gaussian elimination to solve the


system of linear equations below.
2x1 + x2 + x3 + x4 + x5 = 6
x1 + 2x2 + x3 + x4 + x5 = 12

x1+ x2 + 2x3 + x4 + x5 = 24
x1 + x2 + x3 + 2x4 + x5 = 48
x1 + x2 + x3 + x4 + 2x5 = 96
Solution:
R1 * 1/2

|
|
[

]
|
|

R2 R1
R3 R1

]
|

R4 R1
R5 R1

R2 * 2/3

|
|
[

]
|
|

R3 1/2R2

|
[

R4 1/2R2
R5 1/2R2

|
|

R3 * 3/4

|
[

]
|
|
|

R4 1/3R3
R5 1/3R3

|
|
|
[

R4 * 4/5

]
|
|
|

R5 1/4R4

|
|
|
[

]
|
R5 * 5/6

|
[

x1 + x2 + x 3 + x 4 + x 5 = 3
x2 + 1/3 x3 + 1/3x4 + 1/3x5 =
x3 + 1/4x4 + 1/4x5 =

27

/2

x4 + /5x5 = 30
x5 = 65

Therefore,
x5 = 65
x4 = 30 - 1/5(65) ; x4 = 17
x3 = 27/2 - 1/4(17) - 1/4(65); x3 = -7
x2 = 6 - 1/3 (-7) - 1/3(17) - 1/3(65) ;
x2 = -19
x1 = 3 - (-19) - (-7) - (17) -
(65) ; x1 = -25

x1 = -25
x2= -19
x3 = -7
x4= 17
x5 = 65
III.

Exercises

Use Gaussian elimination to find the solution to the


given linear system.
1.

x1 + 3x2 + 4x3 = 3
2x1 + 7x2 + 3x3 = 7
2x1 + 8x2 + 6x3 = 4

2.

2x1 + 8x2 4x3 = 0


2x1 + 11x2 + 5x3 = 9
4x1 + 18x2 + 3x3 = 11

3.

2x2 + 6x3 = 2
3x1 + 9x2 + 4x3 = 7
x1 + 3x2 + 5x3 = 6

4.

x1 2x2 6x3 = 12
2x1 + 4x2 + 12x3 = 17
x1 4x2 12x3 = 22

5.

x1 + 3x2 + 2x3 + 5x4 = 11


x1 + 2x2 2x3 + 5x4 = 6
2x1 + 6x2 + 4x3 + 7x4 = 19
5x2 + 2x3 + 6x4 = 5

1-3 GAUSS- JORDAN ELIMINATION


I.

Introduction
Gauss Jordan Elimination is a method of solving
linear equations. This method is done by transforming the
systems augmented matrix to reduced-row echelon form
by means of row operations.
Reduced row-echelon form:
(1) each row starts with an initial 1 (0s to the left of it)
(2) each initial 1 is to the right of the one in the row above
(3) there are 0s below and above each initial 1
(4) rows of all zeroes will be at the bottom

II.

Solved Examples
1. Solve the following system of linear equation using Gauss
Jordan Method.
x+y=7
2x + 3y =18
Solution:
[

]
[

)
] )

] )

Hence,
x = 3 and y = 4
2.

Solve the following system of linear equation using Gauss


Jordan Method.
x+y+z=3
2x + 3y +7z = 0
x + 3y 2z = 17
Solution:
[

[
Hence,
x = 1, y = 4, z = -2

3.

An electronics engineer supervises the production of


three types of electrical components. Three kinds of
materialmetal, plastic, and rubberare required for
production. The amounts needed to produce each
component are:
Metal
Plastic
Rubber
(g/componen (g/componen (g/componen
t)
t)
t)
1
15
0.25
1.0
2
17
0.33
1.2
3
19
0.42
1.6
If totals of 2.12, 0.0434, and 0.164 kg of metal,
plastic, and rubber, respectively, are available each day,
how many components can be produced per day? Use
Gauss Jordan elimination to solve the problem.

Componen
t

Solution:
15x1 + 17x2 + 19x3 = 2120
0.25x1 + 0.33x2 + 0.42x3 = 43.4
x1 + 1.2x2 + 1.6x3 = 164
R1 * 1/15

R2 0.25R1
R3 R1

|
|

R2 * 150/7

]
R1 17/15R2

|
|
[

R3 1/15R2

]
|
|

[
[

R3 * 70/13

R1 + 87/70R3
R2 - 31/14R3

X1 = 20
X2 = 40
X3 = 60
Hence, the number of components that can be
produced per day is 120 components
III. Exercises
Solve the following linear equations using Gauss Jordan Method.
1. x1 + 5x2 = 7
2x1 7x2 = 5.
2. 2x +4 y = 10
4x + y =6

3.

4.

5.

2x2 + x3 = 8
x1 2x2 3x3 = 0
x1 + x2 + 2x3 = 3
x + 3y + 5z = 22
2x + 4y +6z = 28
x + 2y + 4z = 17
x1 2x2 6x3 = 12
2x1 + 4x2 + 12x3 = 17
x1 4x2 12x3 = 22

1-4 JACOBI METHOD


I.

Introduction
An iterative technique named after Carl Gustav
Jacob``Jacobi(1804- 1851). In numerical linear algebra,
the Jacobi method (or Jacobi iterative method) is an
algorithm for determining the solutions of a diagonally
dominant system of linear equations.
Two assumptions made on Jacobi Method
1.

The system is given by

has a unique solution

2.

The equation is on the form AX = B, where A is a


coefficient matrix. The coefficient of matrix A has no
zero on its main diagonal, namely
are non-zero. If any of the diagonal entries
are zero, then rows and columns must
be interchanged to obtain matrix that have non zero
entries in the main diagonal. Convergence of iteration
depends upon the condition that the system must be
diagonally dominant

Diagonally Dominant
The coefficient on the diagonal must be atleast
equal to the sum of the coefficient in that row and atleast
one row with a diagonal coefficient greater than the sum of
the other coefficient in that row.
Diagonally Dominant means:
| | | | (I = 1, 2, ,n)

Generalized form of Jacobi Method


If

Where k = 0, 1, 2 . . .

are the kth iterates

II. Solved Example


n
0
1
2
3
4
5
6
7
8
9
10

1.

X1
0
0.666667
0.6
1.044445
1.024445
1.011852
0.997704
0.998790
0.999691
1.000117
1.000051

X2
0
3
2.1333333
2.033333
1.962221
1.994444
2.000148
2.001445
2.00080
1.999947
1.999946

Test for diagonally dominant

Solve for

| | | |
] | | | |
| | | |

| |
| |
| |

X3
0
28
3.266667
3.106667
2.997778
2.987555
2.996518
3.000489
3.000531
3.000100
2.999966

2.

Test for diagonally dominant

| | | |
] | | | |
| | | |

|
|
|

|
|
|

Solve for
n
0
1
2
3
4
5
6
7
8
9
10

X1
0
3.148150
2.156930
2.491670
2.400930
2.431550
2.423230
2.426030
2.425270
2.425520
2.425460

X2
0
4.8
3.269130
3.685250
3.545130
3.583270
3.570460
3.573950
3.572780
3.573100
3.573000

X3
0
2.037040
1.889850
1.936550
1.922650
1.926920
1.925650
1.926040
1.925930
1.925960
1.925950

3.

n
0
1
2
3
4
5
6
7

X1
0
-0.2
0.146031
0.191745
0.180881
0.185358
0.186325
0.186053

Test for diagonally dominant


| | | |
[
] | | | |
| | | |
Solve for

III.

Exercises

1.

X2
0
0.222222
0.203174
0.328394
0.332345
0.329260
0.331160
0.331294

| |
| |
|

X3
0
-0.428571
-0.517460
-0.415873
-0.420700
-0.424369
-0.422649
-0.422641

2.

3.

4.

5.

1-5 GAUSS- SEIDEL METHOD


I. Introduction
In numerical linear algebra, the GaussSeidel method, also
known as the Liebmann method or the method of successive
displacement, is an iterative method used to solve a linear system of
equations. It is named after the German mathematicians Carl

Friedrich Gauss and Philipp Ludwig von Seidel, and is similar to the
Jacobi method. Though it can be applied to any matrix with nonzero elements on the diagonals, convergence is only guaranteed if
the matrix is either diagonally dominant, or symmetric and positive
definite. The Gauss-Seidel method is a technique for solving the n
equations of the linear system of equations Ax=b one at a time in
sequence, and uses previously computed results as soon as they are
available,

There are two important characteristics of the Gauss-Seidel


method should be noted. Firstly, the computations appear to be
serial. Since each component of the new iterate depends upon all
previously computed components, the updates cannot be done
simultaneously as in the Jacobi method. Secondly, the new iterate
xk depends upon the order in which the equations are examined. If
this ordering is changed, the components of the new iterates will
also change.

II. EXAMPLES
n
0
1
2
3

X1
0
0.75
0.911458
1.001007

X2
0
2.5
2.004464
1.998498

X3
0
3.145833
3.008494
2.999540

4
5

1.000260
0.999996

1.999991
2.000004

2.999976
3.000001

X1
0
0.75
0.9375
0.993303
0.999495
0.999973

X2
0
1.75
1.979166
1.998759
1.999961
2.000002

X3
0
-1
-1.005952
-1.000779
-1.000066
-1.000004

1.

Solve for

2.
n
0
1
2
3
4
5

Solve for

3.
n
0
1
2
3
4

Solve for

X1
0
1.3
0.9984
0.998691
0.999917

X2
0
1.04
1.00672
1.000297
0.999993

X3
0
0.936
0.939648
1.000232
1.000017

III. EXERCISES
1.

2.

3.

4.

5.

1-6 LU DECOMPOSITION

I.

Introduction
LU(Lower Upper) Decomposition or LU factorization
was introduced by Alan Turing in 1948.
LU decomposition is a way to break or factor a matrix A

A=[

down into the product of two matrices: one lower triangular


and the other upper triangular.
In the lower triangular matrix all elements above the
diagonal are zero.
Let matrix L be the lower triangular matrix

L =[

In the upper triangular matrix, all the elements below


the diagonal are zero.
Let matrix U be the upper triangular matrix

U=[
A = LU
[

]=[

]x[

Computers usually solve square systems of linear


equations using the LU decomposition, and it is also a key step
when inverting a matrix, or computing the determinant of a
matrix.
Application to Solutions in Linear Equation
L

Z = C

][ ] = [ ]

UX=Z
[

][ ]= [ ]

II.

Solved Examples

Example 1
Solve the following Linear Equation.

A=[

+3

=1

=3

C=[ ]

Step 1
[

] x

l21 =
[

] 2nd row

Step 2
[

] x [

Step 3
[

][ ] = [ ]
=3
=

z=[ ]

][ ]=[ ]
=
= -2

x=[

Example 2
Solve the following equation.
9

+3

= 18

+2

= 11

16
A=[

+4

] C=[

= 27
]

Solution:
Step 1
[
l21 =

] x

[
[

]
]

] x

2nd row

Step 2
[

l31 =

3rd row

Step 3

] x (-2) =

] l32 = -2

]
[

3rd row

Step 4

x [

] = [

LZ=C
A=[

] C=[

]x[

][ ]=[

= 18
= 11 - (18) = 3
= 27 [

(18) + 2(3) = 1
]

UX=Z

]x[ ]=[

=1

] =2

= [3 =3
x=[ ]

X=[

Example 3
Solve the following Linear Equation.
0.1
+7
0.3

0.2

-0.2
0.3
+ 10

= 7.85
= -19.3
= 71.4

L=[

U=[
LZ=C

][ ] = [

z=[

UX=Z
[

][ ]=[

= 6.993
x=[

III. Exercises
1. Solve the following linear equation
+2
+5

2.

=6

= 10

Solve the following linear equation


+2

+3

=5

-4 +6

= 18

=6

-3

3.

Solve the following linear equation


2 - + 2 = -1
- 6 + 3 = 13
-4 2 - 8 = -6

4.

Solve the following linear equation


2 + + 3 = 13
+ -2 =7
3 2 + 4 = -5

5.

Solve the following linear equation


2 + + +3 +2
+2 +2 + +
+2 +9 + +5
3 + + +7 +
2 + + 5 + +8

= -2
=4
=3
= -5
=1

1-7 CHOLESKY METHOD

I.

Introduction

LU decomposition (where 'LU' stands for 'Lower Upper',


and also called LU Factorization) factors a matrix as the product
of a lower triangular matrix and an upper triangular matrix. The
product sometimes includes a permutation matrix as well. It is
one method to solve systems of linear equation.

One particular methods of obtaining LU Decomposition of a


matrix is called Cholesky Method. In this method, there is no
diagonal of 1s. However, the lower triangular and upper
triangular matrices are transpose of each other.

Where:

II.

Examples
1.
Determine the L and U resulting from a Cholesky
Method Decomposition.
[

] [

Using Matrix Multiplication, we will find the unknown

Solution:

Hence,

2.
(a)Suppose that Cholesky Method Decomposition is
required to decompose the coefficient matrix derived from the
system of linear equation shown below. (b) Solve the system of
linear equation using LU Decomposition method.

] [

Using Matrix Multiplication, we will find the unknowns

Hence,

Solution for (b):


Using forward substitution,

Using back substitution,

Hence,
[

3.
(a) Suppose that Cholesky Method Decompositionis
required to decompose the coefficient matrix derived from the
system of linear equation shown below.(b) Solve the system of
linear equation using LU Decomposition method.

First, we need to determine


Method Decomposition.

resulting from the Cholesky

Using Matrix Multiplication, we will find the unknown


Solution for (a):

Hence,

Solution for (b):


Using forward substitution,

] [

Using back substitution,

] [

Hence,

III. Exercises
1. Determine the L and Uresulting from the Cholesky
Method.

2.

Find L andUfrom the given matrix using Cholesky


Method.

3.

Find L and Ufrom the given matrixusing Cholesky


Method.

4.

Determine the L and Uresulting from the Cholesky


Method. Then, solve the system of the linear equation
using LU decomposition method. Write the
corresponding unknown matrix X.

5.

Determine the L and Uresulting from the Cholesky


Method. Look for the temporary matrix Z.

CHAPTER

2
SOLUTIONS TO
NON-LINEAR
EQUATIONS
A nonlinear system of equations is a set of simultaneous equations in
which the unknowns appear as variables of a polynomial of degree higher than
one or in the argument of a function which is not a polynomial of degree one. In
other words, in a nonlinear system of equations, the equation(s) to be solved
cannot be written as a linear combination of the unknown variables or functions
that appear in it (them). It does not matter if nonlinear known functions appear
in the equations.
Nonlinear algebraic equations, which are also called polynomial
equations, are defined by equating polynomials to zero. For example,

An equation is said to be nonlinear when it involves terms of degree


higher than 1 in the unknown quantity. These terms may be polynomial or
capable of being broken down into Taylor series of degrees higher than 1.
Nonlinear equations cannot in general be solved analytically.
In this case, therefore, the solutions of the equations must be
approached using iterative methods. The principle of these methods of solving
consists in starting from an arbitrary point the closest possible point to the

solution sought and involves arriving at the solution gradually through


successive tests.

2-1 BISECTION METHOD


One of the methods used in finding the roots of a function is bisection
method.
To understand the bisection method, we should first define what a root
of the function is. The roots or zeros of a function are the values of x in the
function f(x) such that f(x) = 0. In bisection method, we aim to find this value of
x by assuming an interval [a,b] which contains the zero of the function f(x).
Consider the function f(x) and its graph,

Now, consider the interval [a,b] around the zero of the function f(x)
such that f(a)<0 and f(b)>0. With the given interval [a,b], we can compute for
the midpoint c which is closer to the zero of the function f(x). The interval
would then be reduced by replacing a or b with c depending on the value of f(c)
which would satisfy the condition f(a)<0 and f(b)>0. By doing this repeatedly,
the interval [a,b] will converge to the zero of the function.
Note: for convention, truncate your answer to 6 decimal places. The
iterations will stop when the preceding value and the present value of a, b and c
are equal to 3 decimal places.

Examples
1.

Find the zero of the function

for the interval [0,5]

Solution,
iterations

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

0
0
1.25
1.25
1.5625
1.71875
1.71875
1.71875
1.71875
1.728516
1.728516
1.730957
1.730957
1.731567
1.731873
1.732025
1.732

5
2.5
2.5
1.875
1.875
1.875
1.796875
1.757813
1.738281
1.738281
1.733398
1.733398
1.732178
1.732178
1.732178
1.732178
1.732

2.5
1.25
1.875
1.5625
1.71875
1.796875
1.757813
1.738281
1.728516
1.733398
1.730957
1.732178
1.731567
1.731873
1.732025
1.732101
1.732

3.25
-1.4375
0.515625
-0.55859
-0.0459
0.22876
0.089905
0.021622
-0.01223
0.00467
-0.00379
0.00044
-0.00167
-0.00062
-8.9E-05
0.000175

Thus, the zero of the function is 1.732.


2.

Find the zero of the function

for the interval [2,5]

Solution,
iterations

0
1
2
3
4
5

2
2
2.75
3.125
3.3125
3.40625

5
3.5
3.5
3.5
3.5
3.5

3.5
2.75
3.125
3.3125
3.40625
3.453125

0.013753
-0.26675
-0.13175
-0.06036
-0.02365
-0.00504

6
7
8
9
10
11
12
13

3.453125
3.453125
3.464844
3.464844
3.464844
3.464844
3.465576
3.465576
3.466

3.5
3.476563
3.476563
3.470703
3.467773
3.466309
3.466309
3.465942
3.466

3.476563
3.464844
3.470703
3.467773
3.466309
3.465576
3.465942
3.465759
3.466

0.004335
-0.00036
0.001988
0.000815
0.000229
-6.4E-05
8.26E-05
9.35E-06

Thus, the zero of the function is 3.466.


3.

Find the zero of the function

for the interval [0.5,1.5]

Solution,
iterations

0
1
2
3
4
5
6
7
8
9
10
11
12

0.5
0.5
0.75
0.875
0.9375
0.9375
0.9375
0.9375
0.941406
0.941406
0.942383
0.942383
0.942383
0.942

1.5
1
1
1
1
0.96875
0.953125
0.945313
0.945313
0.943359
0.943359
0.942871
0.942627
0.943

1
0.75
0.875
0.9375
0.96875
0.953125
0.945313
0.941406
0.943359
0.942383
0.942871
0.942627
0.942505
0.943

Thus, the zero of the function is 0.943.

0.283662
-0.82056
-0.33102
-0.02489
0.130984
0.053211
0.014173
-0.00536
0.004408
-0.00047
0.001966
0.000746
0.000135

Exercises
Find the root of the following functions using bisection method.
1.
2.
3.
4.
5.

y=3x^3+2x+1 for interval [-1,0]


y=x^2-6 for interval [0,5]
y=3x^2+2/3 for interval [0,1]
y=tan^(-1)(x)-1 for interval [0,5]
y=x^3+x^2+1 for interval [-2,0]

2-2 NEWTON - RAPHSON METHOD


In numerical analysis, Newton's method (also known as the Newton
Raphson method), named after Isaac Newton and Joseph Raphson, is a method
for finding successively better approximations to the roots (or zeroes) of a realvalued function.

The NewtonRaphson method in one variable is implemented as


follows:
Given a function defined over the reals x, and its derivative ', we
begin with a first guess x0 for a root of the function f. Provided the function
satisfies all the assumptions made in the derivation of the formula, a better
approximation x1 is

Geometrically, (x1, 0) is the intersection with the x-axis of


the tangent to the graph of f at (x0, f (x0)).
The process is repeated as until a sufficiently accurate value is reached.

Examples
Find the value of x using Newton-Rhapson method.
1.
Given:

N
0
1
2
3

5
4.571429
4.497098
4.494941

x = 4.4949

15
1.941702
0.053255
0.000032

35
26.122457
24.694887
24.653955

4.571429
4.497098
4.494941
4.494939

No. of iterations: 3

2.
Given:

n
0
1
2
3
x = 0.6269
3.
Given:

0
0.666666
0.627304
0.626926

2
-0.142739
-0.001342
0.000002

-3
-3.626358
-3.558592
-3.557956

No. of iterations: 3

0.666666
0.627304
0.626926
0.626926

n
0
1
2
3
4
5
6
7
8
9
10
11
12
13

2
2.083333
2.136110
2.170208
2.192493
2.207161
2.216855
2.223284
2.227551
2.230346
2.232176
2.233410
2.233938
2.234596

x = 2.234

-1
-0.287134
-0.083472
-0.024438
-0.007186
-0.002118
-0.000626
-0.000185
-0.000054
-0.000016
-0.000005
-0.000001
-0.0000008
-0.0000002

12
5.440439
2.447966
1.096577
0.489879
0.218468
0.097357
0.043353
0.019316
0.008740
0.004050
0.001891
0.001215
0.000580

2.083333
2.136110
2.170208
2.192493
2.207161
2.216855
2.223284
2.227551
2.230346
2.232176
2.233410
2.233938
2.234596
2.234940

No. of iterations: 13

Exercises
Find the root of the following functions. Use Newton-Raphson Method.
Compare it using Bisection Method and Analytical Method.
1.
2.
3.
4.
5.

2-3 SECANT METHOD


In numerical analysis, the secant method is a root-finding algorithm that
uses a succession of roots of secant lines to better approximate a root of
a function f. The secant method can be thought of as a finite
difference approximation of Newton's method. However, the method was
developed independently of Newton's method, and predated the latter by over
3,000 years.

A root-finding algorithm assumes a function to be approximately linear


in the region of interest. Each improvement is taken as the point where the
approximating line crosses the axis. The secant method retains only the most
recent estimate, so the root does not necessarily remain bracketed. The secant
method is implemented in Mathematica as the undocumented option Method
So the general formula in solving roots for secant method is,

Examples
1.

Solve for the roots of the function,


Method.

Assume

and
n
1
2
3
4
5

5
10
7.4
7.903225
8.005635

Iteration = 4
2.

using Secant

10
7.4
7.903225
8.005635
7.999950

-24
26
-6.24
-1.055159
0.062016

7.4
7.903225
8.005635
7.999950
7.999999

answer=8

Given the function

Assume

26
-6.24
-1.055159
0.062016
-0.000549

find the root using Secant method.

and
n
1
2
3
4
5
6.

3
4
3. 511704
3.680658
3.745598
3.732460

Iteration = 5

4
3. 511704
3.680658
3.745598
3.732460
3.733071

-6.914463
6.598150
-3.490882
-0.969239
0.245802
-0.012007

answer = 3.733

6.598150
-3.490882
-0.969239
0.245802
-0.012007
-0.000155

3. 511704
3.680658
3.745598
3.732460
3.733071
3.733078

3.

Given the function


method.

Assume

find the root using Secant

and
n
1
2
3
4

0
1
0.390662
0.441257

Iteration = 3

1
0.390662
0.441257
0.448770

-1
1.559752
-0.141240
-0.018263

1.559752
-0.141240
-0.018263
0.000242

0.390662
0.441257
0.448770
0.448671

answer = 0.449

Exercises
1.
2.
3.
4.
5.

Find a root of
x 10; Assume
and
Find a root of
- = 1; Assume
and
Find a root of ln(x) 2 = 0; Assume
and
Find a root of x-sin[x]-(1/2) = 0; Assume
and
Find a root of
+
1 ; Assume
and

2-4 REGULA FALSI METHOD


The Regula-Falsi Method (sometimes called the False Position Method)
is a method used to find a numerical estimate of an equation. This method
attempts to solve an equation of the form f(x) = 0. (This is very common in most
numerical analysis applications.) Any equation can be written in this form.
This algorithm requires a function f(x) and two points a and b for which
f(x) is positive for one of the values and negative for the other. We can write
this condition as f(a)f(b)<0. If the function f(x) is continuous on the interval
[a,b] with f(a)f(b)<0, the algorithm will eventually converge to a solution. This
algorithm cannot be implemented to find a tangential root. That is a root that is
tangent to the x-axis and either positive or negative on both side of the root.
For example f(x) = (x-9) 2, has a tangential root at x = 9.

The convergence process in the bisection method is very slow. It


depends only on the choice of end points of the interval [ a , b ]. Regula-Falsi
method can be done by taking the straight line L joining the points ( a , f(a) ) and
( b , f(b) ) intersecting the x-axis. To obtain the value of c we can equate the two
expressions of the slope m of the line L

So the general formula in solving roots for the Regula-Falsi method is,

Examples
1.

Given the function f(x) = x2 5x 24 , find the root using Regula Falsi
Method.
f(x) = x2 5x 24 , [ 5 , 10 ]

Solution:
when n=1
a=5
b=10

f(a) =

f(5)

f(b) = f(10)

= 52 5(5) 24
= -24
= 102 5(10) 24

= 26

f(c ) = f(7.4)

= 7.42 5(7.4) 24
= -6.24

f(a)*f(c)

=(-,-)
=+
And so on when n = 2
n

f(a)

f(b)

f(c)

f(a)*f(c)

10

-24

26

7.4

-6.24

7.4

10

-6.24

26

7.903225

-1.055159

7.903225

10

-1.055159

26

7.984999

-0.164785

7.984999

10

-0.164785

26

7.997689

-0.025415

7.997689

10

-0.025415

26

7.999644

-0.003915

7.999644

10

-0.003915

26

7.999945

-0.000604

x=8
Given the function f(x) = x3 + 3x 5 find the root using Regula Falsi
Method.

2.

f(x) = x3 + 3x 5 , [ 1 ,2 ]
n

f(a)

f(b)

f(c)

f(a)*f(c)

-1

1.1

-0.369

1.1

-0.369

1.135446 -0.129802

3 1.135446 2 -0.129802

1.147737

-0.044874

4 1.147737

1.151965

-0.015420

2 -0.044874

5 1.151965

2 -0.015420

1.153415

-0.005290

6 1.153415

2 -0.005290

1.153912

-0.001815

7 1.153912

2 -0.001815

1.154082 -0.000626

x = 1.154
Given the function f(x) = ex 3x2 find the root using Regula Falsi
Method.

3.

f(x) = ex 3x2 , [ 3 , 4 ]
n

f(a)

f(b)

f(c)

f(a)*f(c)

-6.914463

6.598150

3.511704

-3.490882

3.511704

-3.490882

6.598150

3.680658

-0.969239

3.680658

-0.969239

6.598150

3.721559

-0.221228

3.721559

-0.221228

6.598150

3.730591

-0.048179

3.730591

-0.048179

6.598150

3.732543

-0.010398

3.732543

-0.010398

6.598150

3.732963

-0.002251

3.732963

-0.002251

6.598150

3.733054

-0.000485

x = 3.733

Exercises
1. Find a root of x * cos[(x)/ (x-2)]=0 using Regula Falsi Method
2. Find a root of x2 = (exp(-2x) - 1) / x using Regula Falsi Method
3. Find a root of exp(x2-1)+10sin(2x)-5 = 0 using Regula Falsi Method
4. Find a root of exp(x)-3x2=0 using Regula Falsi Method
5. Find a root of tan(x)-x-1 = 0 using Regula Falsi Method

CHAPTER

3
NUMERICAL
DIFFERENTIATION & INTEGRATION

3-1 NUMERICAL DIFFERENTIATION


I.

Introduction
Let f be a given function that is only known at a number of
isolated points. The problem of numerical differentiation is to compute
an approximation to the derivative f 0 off by suitable combinations of
the known values off.
Recall that:

Assume that h = 0.001


h = 0.0001 for more accurate result.

II.

Solved Examples
1. Determine the derivatives of
Use analytical and numerical method.
Solution: Analytical Method

when x is equal to

-23.141
Solution: Numerical Method

-23.141

2.

Determine the derivatives of


numerical method.

when x = 5. Use

2.609
3.

Using numerical differentiation, determine


x = 4. Let h = 0.0001 for more accurate result.

-0.6536

if

III.

Exercises
1.
2.
3.
4.
5.

Determine the derivatives of


with analytical method.
Find f(3) :
.
Determine the derivatives of
Compare with analytical method.
Determine the derivatives of
Find f(x) :

when x = 0.5. Compare

when x = 0.8.

when x = 8.

3-2 NUMERICAL INTEGRATION


Numerical integration is the approximate computation of an integral
using numerical technique.
Numerical integration constitutes a broad family of algorithms for
calculating the numerical value of a definite integral, and by extension, the term
is also sometimes used to describe the numerical solution of differential
equations. This article focuses on calculation of definite integrals. The term
numerical quadrature (often abbreviated to quadrature) is more or less a
synonym for numerical integration, especially as applied to one-dimensional
integrals. Numerical integration over more than one dimension is sometimes
incorrectly described as cubature, since the meaning of quadrature is
understood for higher-dimensional integration as well.
The basic problem in numerical integration is to compute an
approximate solution to a definite integral

to a given degree of accuracy. If f(x) is a smooth function integrated


over a small number of dimensions, and the domain of integration is bounded,
there are many methods for approximating the integral to the desired precision.

3.2.a TRAPEZOIDAL RULE

I.

INTRODUCTION

Trapezoidal Rule is the process of finding or evaluating a definite


integral. I =
from a set of numerical values of the integral f(x). It is
a way to find an approximate value for a given numerical integration, which
based on calculating the sum of the area of the curve. This is known as
method of approximate integration. We can find the total area under the
given curve f(x) with the help of Trapezoidal rule and also estimate the
integral
.
We assume that f(x) is continuous on [a, b] and we divide [a, b] into n
subintervals of equal length
=
using the n + 1 points
x0 = a,

x1 = a + x,

x2 = a + 2x, . . . , xn = a + nx = b.

We can compute the value of f(x) at these points.


y0 = f(x0),

y1 = f(x1),

y2 = f(x2), . . . ,yn = f(xn)

We approximate the integral by using n trapezoids formed by using straight


line segments between the points (xi1, yi1) and (xi , yi) for 1 i n as
shown in the figure below.

By adding the area of the n trapezoids, we obtain the approximation

which simplifies to the trapezoidal rule formula.

Where:
(Also known as h)
n= no. of segments

II.

SOLVED EXAMPLES

1. Evaluate the integral I=


SOLUTION:
Using Analytical Method:
I=
I= [

I= [

]-[

I= -7.33
Using Trapezoidal Method:
f(2)= -4 ; f(4)= -2
I
I
I -6

2. Redo the previous problem using h= 0.5


SOLUTION:
I=
I [f(a) + 2f(1) + 2f(2) +2f(3) + f(b)]

[-4+ 2(-4.25-4-3.25)-2]

I -7.25
Check (Using Calculator)
Set calculator to MODE 7, input equation and steps to acquire the table.
X
2
2.5
3
3.5
4

3. Approximate the integral of f(x) =

f(x)
-4
-4.25
-4
-3.25
-2

on the interval [1, 2] with

four subintervals.
SOLUTION:
First, solve for h:
n= 4
h=
h=

= 0.25

and thus we calculate:


I [f(a) + 2f(1) + 2f(2)+ 2f(3) + f(b)]
I

[-5.281 + 2(-4.759) + 2(-4.018) + 2(-2.995) + (-1.61)]

I -3.80437

x
1
1.25
1.5
1.75
2

III.

F(x)
-5.281
-4.759
-4.018
-2.995
-1.61

EXAMPLES
1.

Using

, approximate the value of

2.

Numerically approximate the


integral
with n = 8 subintervals.

by using the trapezoidal rule

3.

Numerically approximate the integral


using the trapezoidal rule with n = 10 subintervals.

4.

Use the trapezoidal rule with n = 8 to estimate

5.

The following points were found empirically.


x
y

2.1
3.2

2.4
2.7

2.7
2.9

Use the trapezoidal rule to estimate

3.0
3.5

3.3
4.1

by

3.6
5.2

3.2.b. Simpsons Rule


Simpsons rule is a numerical method that approximates the value of a definite
integral by using quadratic polynomials. The numerical integration technique
known as "Simpson's 3/8 rule" is credited to the mathematician Thomas
Simpson (1710-1761) of Leicestershire, England. His also worked in the areas of
numerical interpolation and probability theory.
In Simpsons 1/3 rule for integration was derived by approximating the
integrand

f (x)

with a 2nd order (quadratic) polynomial function

f 2 ( x ) where

f 2 ( x) a0 a1 x a2 x .
2

~
f ( x) Cubic function.
Simpson 3/8 rule for integration can be derived by approximating the
given function

f (x)

with the 3rd order (cubic) polynomial f 3 ( x ) .

f 3 ( x ) a0 a1 x a 2 x 2 a3 x 3

a0

1
2
3
1, x, x , x

a 2

3
The unknown coefficients a0 , a1 , a2 and a3 can be obtained by
substituting 4 known coordinate data points

{x0 , f x0 },{x1 , f x1 },{x2 , f x2 } and {x3 , f x3 } .

f ( x0 ) a0 a1 x0 a 2 x02 a3 x02

f ( x1 ) a0 a1 x1 a 2 x12 a3 x12

f ( x 2 ) a0 a1 x 2 a 2 x 22 a3 x 22
f ( x3 ) a0 a1 x3 a 2 x32 a3 x32

where:

Substituting the form of f 3 x from this method.


b

I f x dx
a
b

f 3 x dx`
a

b a

f x0 3 f x1 3 f x2 f x3
8

Since

ba
,
3

then b a 3h

The simplified equation will be

3h
f x0 3 f x1 3 f x2 f x3
8

For multiple segments for Simpsons 3/8 rule, where n = number of


equal segments, the width h can be defined as

ba
n

The number of segments need to be an integer multiple of 3 as a single


application of Simpson 3/8 rule requires 3 segments.
The integral of a function can be expressed as

I f x dx
a
b

f 3 x dx
a
x3

xn b

x6

f x dx f x dx ........ f x dx

x0 a

x3

xn 3

Using Simpson 3/8 rule, one gets

3h f x0 3 f x1 3 f x2 f x3 f x3 3 f x4 3 f x5 f x6

8 ..... f xn3 3 f xn2 3 f xn1 f xn

n 2
n 1
n 3

3h
f x0 3 f xi 3 f xi 2 f xi f xn
8
i 1, 4, 7 ,..
i 2 ,5,8,..
i 3, 6, 9 ,..

Simpsons 3/8 rule is a Newton-Cotes formula for approximating the integral of a


function using cubic polynomials. Simpson's 3/8 rule is a 4-point closed rule.
The General formula for the rule is given by;
( )

]
Where:
Interval gap ( ) =

EXAMPLES
1.

Approximate I=

by Simpson's 3/8 rule with n = 9

Solution :

0
1
2
3
4
5
6
7
8
9

1
1.111111
1.222222
1.333333
1.444444
1.555555
1.666666
1.777777
1.888888
2

0.5
0.447513
0.40099
0.36
0.324
0.292418
0.264705
0.240356
0.218918
0.2
( )

( )

[
]

I
I

0.3217497917

2.

Approximate I=

with h=0.2

Solution :

0
1
2
3
4
5
6

0
0.2
0.4
0.6
0.8
1
1.2

1
0.818730
0.670320
0.548811
0.449328
0.367879
0.301194
( )

[
]
I

0.698819025

I
3.

Approximate l=
Solution:

0
1
2
3
4
5
6
7
8
9

0
0.342020
0.642787
0.866025
0.984807
0.984807
0.866025
0.642787
0.342020
0

/9

( )

( )

[
]

2.000380848
I

EXERCISES

1.

Numerically approximate the integral


using Simpson's 3/8 rule with m = 10, 20, 40, 80, and 160.

2.

Determine the integral of the function

by

by Simpsons 3/8

rule with limit from 3 to 6 with n = 9. Use analytical and numerical


methods.

3.

The vertical distance covered by a rocket from


seconds is given by

x 8 to x 30

140000

s 2000 ln
9.8 x dx

140000 2100t

8
30

Use Simpson 3/8 rule to find the approximate value of the integral.
4.

Use Simpsons rule with n = 6 to estimate

5.

Find

method.

with n = 9 using analytical and numerical

CHAPTER

4
CURVE FITTING
Curve fitting is the process of constructing a curve, or mathematical
function that has the best fit to a series of data points, possibly subject to
constraints.
Curve fitting can involve either interpolation, where an exact fit to the
data is required, or smoothing, in which a "smooth" function is constructed that
approximately fits the data.
A related topic is regression analysis, which focuses more on questions
of statistical inference such as how much uncertainty is present in a curve that is
fit to data observed with random errors. Fitted curves can be used as an aid for
data visualization, to infer values of a function where no data are available, and
to summarize the relationships among two or more variables.
Extrapolation refers to the use of a fitted curve beyond the range of
the observed data, and is subject to a degree of uncertainty since it may reflect
the method used to construct the curve as much as it reflects the observed
data.
Starting with a first degree polynomial equation:

This is a line with slope a. A line will connect any two points, so a first
degree polynomial equation is an exact fit through any two points with distinct
x coordinates.

If the order of the equation is increased to a second degree polynomial,


the following results:

This will exactly fit a simple curve to three points.


If the order of the equation is increased to a third degree polynomial,
the following is obtained:

This will exactly fit four points.

4-1 LINEAR REGRESSION


Linear regression is commonly used method for examining the
relationship between quantitative variables and for making predictions. Linear
equations with one independent variable, explain how to find the regression
equation, the equation of the line that best fits a set of data points. Treat them
that they may fall into line.

Mean:

Standard Deviation:

Correlation Coefficient:

Coefficients:

Examples
1.
a.
b.

Given the set of data below, determine:


The linear regression
y(8)
x
1
2
3
4
5

a.

y
1
2
1.3
3.75
2.25

[
[

] [
][

b.
y is 4.185 when x is 8

2.

The following form is an arithmetic progression 1, 4, 7, 10 using linear


regression, r = 1:
Identify the 8th term
Calculate what term does 25 occur

a.
b.

10

a.
The 8th term is 22
b.

25 occurs at the 9th term

3.

Given the following data below, find the linear regression.


x

] [
][

Exercises
1.

2.

3.

Given the following data, find y(18).

Given the
regression.

12

19

29

37

45

-2

-1

following data, find the linear

Given the following data, find the value of x that will make y equal to
200.
x

32

68

20

86

30

122

50

4.

5.

158

70

194

90

212

100

Given the following data, find the linear regression.


x

-1

Given the following data, find the linear regression.


x

0.7

0.19

0.96

0.21

1.13

0.23

1.57

0.25

1.92

0.31

4-2 POLYNOMIAL REGRESSION


Polynomial regression is a form of linear regression in which the
relationship between the independent variable x and the dependent variable y
is modelled as an nth degree polynomial.
The least-squares procedure can be readily extended to fit the data to a
higher-order polynomial. Consider the general form for a polynomial of order j
f(x)= a0 + a1x + a2x2 + a3x3 + + ajxj = a0 +

(1)

The general expression for any error using the least squares approach is
err = (di)2 = ( y1 f(x1))2 + (y2 f(x2))2 + ( y3 f(x3))2 + (y4 f(x4))2

(2)

where we want to minimize this error. Now substitute the form of our
eq. (1) into the general least squares error eq. (2)
err =

(y1 (a0 + a1x + a2x2 + a3x3 + + ajxj ))2

(3)

where: n - # of data points given, i - the current data point being


summed, j- the polynomial order re-writing eq. (3)
err =

(y1 (a0 +

))2

(4)

To minimize eq. (4), take the derivative with respect to each coefficient
set each to zero

)]

)]

)]

)]

:
:
[

Re-write these j + 1 equations, and put into matrix form

=
] [ ] [

where all summations above are over i = 1, , n


We already know how to solve this problem. Remember Gaussian
elimination?

A=
[

, B=

, X=
]

[ ]

Note: No matter what the order, we always get equations LINEAR with
respect to the coefficients. This means we can use the following solution
method
AX = B
X= A-1*B

Examples
1.

Fit a second order polynomial to the data.


i
x
y

1
0
0

2
0.5
.25

3
1.0
1.0

4
1.5
2.25

5
2.0
4.0

Since the order is 2 (j =2), the matrix form to solve is

n=6
xi = 7.5
x2i = 13.75
x3i = 28.125
x4i = 61.1875
[

] [ ]=[

yi = 13.75
xi yi = 28.125
x2i yi = 61.1875

][ ]=[

Note: we are using x2i, NOT (xi )2. Theres a big difference
Using the inversion method
[ ]= inv [

]x[

Or use Gaussian elimination gives us the solution to the coefficients


[ ] = [ ] f(x) = 0 + 0*x + 1*x2
f(x) = x2

6
2.5
6.25

2.

Fit a second- order polynomial to the data

i
x
y
xi = 15
n=6
x = 2.5
y = 25.433

1
0
2.1

2
1
7.7

3
2
13.6
x4i = 979
yi = 152.6
x2i = 55
x3i = 225

4
3
27.2

5
4
40.9

xi yi = 585.6
x2i yi = 2488.8

Therefore, the simultaneous linear equation are


[

][

Therefore, the least-squares quadratic equation for this case is


f(x) = 2.4786 + 2.3593x + 1.8607x2

3.

Fit a second- order polynomial to the data

x= [
y= [

0
2.1

1
7.7

2
13.6

3
27.2

4
40.9

6
80.3

];
];

The result is

]=[

] f(x) =

f(x) =

x+

*x +

*x2

x2

Exercises
1.

Fit a second- order polynomial to the data


x = [0
0
y = [0.0674 -0.9156

1
1.6253

1.5
3.0377

6
5
61.1

2
2.5]
3.3535 7.9409]

2.

Fit a second order polynomial to the data

I
T (F)
(in/in/F)

1
80
6.47

2
40
6.24

3
-40
5.72

4
-120
5.09

5
-200
4.30

3.

Find (70) in question no.2.

4.

A projectile is fired upwards from the ground. The height of the


projectile above the ground is shown in the following table:

I
Time (s)
Height(ft)

1
0
0

2
0.5
20.5

3
1
31.36

4
1.5
36.25

6
-280
3.33

5
2
30.41

6
2.5
28.23

a) Find a good model to fit this data.


b) Find the time at which the projectile hit the ground.
5.

Healthcare costs have been increasing over the years. The following
data shows the average cost of healthcare per person from 1976 to
1998:

i
1
Year
1976
Cost
618
(per person)
Hint: x0=1970.

2
7980
860

3
1987
1324

4
1993
1865

5
1998
2256

a) Find a model that fits the data well.


b) Find the time the average healthcare cost will reach $2800 per person.

4-3 LINEAR INTERPOLATION


Linear interpolation is a simplest form of interpolation that assumes a
straight line (linear) relationship between the known points; it essentially means
averaging the two rates over the interpolation period.

The formula for linear interpolation is:

It can be derived geometrically as follow,

Examples
1.

Given the following data:


X

12

16

Using linear interpolation, determine x (10).


Solution:
)

2.

Given the following data:


x

25

10

35

15

45

20

25

65

Using linear interpolation, determine .


Solution:
)

3.

Suppose that you are to find the specific weight (y) for water at
temperature T = 62.5 F. Given the following data:

T(F)

y(

60.0

62.37

62.5

70.0

62.30

Solution:
)

Exercises
1.

Using linear interpolation formula, for the given coordinates of (1, 2)


and (4, 5). Find the value for y when x = 2.

2.

Using the linear interpolation formula, find the equation for the given
coordinates (6, 8) and (10, 16).

3.

Find the value of y at x = 0 given some set of values (-2, 5), (1, 7), (3, 11),
(7, 34).

4.
(a)
(b)

Find values of at
T = 210
T = 225
T

200

100

220

140

240

190

5.
Find the values of , and u at
(a) T = 330 K
(b) T = 335 K
Properties of Superheated Steam at P = 0.006 MPa
T (K)

(kg/m3 )

(m3/kg)

u (kJ/kg)

320

0.040708

24.565

2439.7

340

0.038291

26.116

2468.4

360

0.036151

27.662

2497.0

4-4 QUADRATIC INTERPOLATION


In numerical analysis, Quadratic Interpolation, also called Three point
Interpolation, is a root-finding algorithm; it is an algorithm for solving equations
of the form

We have three points on an xy-coordinate system, that can be defined


as (x0, x1), (y0, y1), (x2, y2). The only condition for the initial values:

value of

There are no restrictions for the values of y0, y1, and y2. To find out the
to an arbitrary point , use the formula:

Examples
1.

Find the value of


following data:

using Quadratic Interpolation. Given the

10

15

20

22.5

30

f(x)

227.04

362.78

517.35

602.97

901.67

Solution:
Use the formula
(a)
From the given table, 16 is closest to 10, 15 and 20.
Substitute to (a)
For 10,
For 15,
For 20,
From the obtained formula:

Substitute the values obtained to (a)

2.

Find

using Quadratic Interpolation. Given the following data


x

5.15

8.39

10.32

14.1

f(x)

2.75

9.451

16.31

34.78

45.3

Solution:
Use the formula
(a)
From the given table, 3.02 is closest 0, 5.15, and 8.39.
Substitute to (a)
For 0,

For 5.15,
For 8.39

Therefore,

Substitute to (a)

3.

Obtain an estimate of sin(0.55) by Quadratic Interpolation of f (x) = sin


x using the data
x

0.5

0.6

0.7

f(x)

0.47943

0.56464

0.64421

Compare your estimate with the value of

given by your calculator.

Solution:
Use the formula
Substitute 0.5 and 0.6 to (a)
For 0.5,
For 0.6,

(a)

For 0.7,

Therefore,

Substitute the values obtained to (a)

By calculator

Exercises
1.

Given the data below, find


x
f(x)

2.

Find

4.5
14.87

5.3
16.12

7.65
20.76

0.045
0.581

0.098
0.862

0.15
0.367

0.29
0.738

0.32
0.912

Find f(-2.5) using Quadratic Interpolation, given the following data


x
f(x)

4.

2.9
7

using Quadratic Interpolation, given the following data


x
f(x)

3.

0.564
4.573

using Quadratic Interpolation.

-4.17
-15.28

-3.49
-9.72

Given the data below, find

-1.52
-4.89

-0.98
-1.60

1.23
2.69

2.75
5.43

using Quadratic Interpolation.

5.

10

15

20

f(x)

14

26.5

32.8

52

Given the data below, find

using Quadratic Interpolation.

13.46

23.79

32.94

40.12

f(x)

18.90

31.2

49.32

60.31

4-5 NEWTONS DIVIDED DIFFERENCE METHOD


Let us assume that the function (x) is linear then we have
,
where xa and xb are two tabular points and is independent of xa and xb. This
ratio is called the first divided difference of (x) relative to xa and xb and
denoted by (xa, xb). That is
[

Since the ratio is independent of xa and xb we can write f(x0, x) = f(x0, x1)
[

[x0, x1]
By this formula, (x) can be approximated at any point x.

For the table:


a

Xa

Xb

Xc

Lets first get the first divided difference,


[xa, xb] =

; f[xb, xc] =

To get the second divided difference, we have,


[xa, xb, xc] =
Since it is independent of xa, xb and xc, let
[x1, x0, x] = [x0, x1, x2]
[

[x0, x] = [x0, x1] + (x - x1) [x0, x1, x2]


[ ]

(x) = [x0] + (x - x0) [x0, x1] + (x - x0) (x - x1) [x0, x1, x2]
The kth degree polynomial approximation to f(x) can be written as
(x) = [x0] + (x - x0) [x0, x1] + (x - x0) (x - x1) [x0, x1, x2]
+ . . . + (x - x0) (x - x1) . . . (x - xk-1) [x0, x1, . . . , xk]
This formula is called Newton's Divided Difference Formula.
Once we have the divided differences of the function relative to the tabular
points then we can use the above formula to compute (x) at any non-tabular
point.

Examples
1.

Given the following set of data, find

0
1
3
4
7

1
3
49
129
813

using NDDM.

Solution:
First divided difference
f[0, 1] =
f[1, 3] =
f[3, 4] =
f[4,7] =
Second divided difference
f[0, 1, 3] =
f[1, 3, 4] =
f[3, 4, 7] =
Third divided difference
f[0, 1, 3, 4] =
f[1, 3, 4, 7] =
Fourth divided difference
f[0, 1, 3, 4, 7] =

f(x) = f(0) + (x - 0)( f[0, 1]) + (x - 0)(x - 1) (f[0, 1, 3]) +(x - 0)(x - 1)(x - 3)( f[0, 1, 3, 4])
+ (x - 0)(x - 1)(x - 3)(x - 4)(f[0, 1, 3, 4, 7])

2.

Determine

given the following set of data using NDDM.

0
0.5
1
2

1
1.8987
3.7183
11.3891

Solution:
First divided difference
f[0, 0.5] =
f[0.5, 1] =
f[1, 2] =
Second divided difference
f[0, 0.5, 1] =
f[0.5, 1, 2] =
Third divided difference
f[0, 0.5, 1, 2] =

f(x) = f(0) + (x - 0)( f[0, 0.5]) + (x - 0)(x 0.5) (f[0, 0.5, 1]) +(x - 0)(x 0.5)(x - 1)(
f[0, 0.5, 1, 2])

3.

Given the following set of data, find

0
1
3
5
7
10
Solution:
First divided difference
f[0, 1] =
f[1, 3] =
f[3, 5] =
f[5, 7] =
f[7, 10] =
Second divided difference
f [0, 1, 3] =
f[1, 3, 5] =
f[3, 5, 7] =
f[5, 7, 10] =
Third divided difference
f[0, 1, 3, 5] =
f[1, 3, 5, 7] =
f[3, 5, 7, 10] =
Fourth divided difference
f[0, 1, 3, 5, 7] =
f[1, 3, 5, 7, 10] =

using NDDM.

0
1.18
10.7
25.8
63.2
159.1

Fifth divided difference


f[0, 1, 3, 5, 7, 10] =

f(x) = f(0) + (x - 0)( f[0, 1]) + (x - 0)(x - 1) (f[0, 1, 3]) +(x - 0)(x - 1)(x - 3)( f[0, 1, 3, 5])
+ (x - 0)(x - 1)(x - 3)(x - 5)(f[0, 1, 3, 5, 7]) + (x - 0)(x - 1)(x - 3)(x - 5)(x - 7)(f[0, 1, 3, 5,
7,10])

Exercises
1.

Given the following set of data, find

0
2
4
6

1.5
2.5
7
11

using NDDM.

2.

Given the following set of data, find

0
2
4
6
3.

Determine

Determine

Determine

4.5
9
11.75
19.55

given the following set of data using NDDM.


0
5
7
10

5.

1.5
2.5
7
11

given the following set of data using NDDM.

0
5
7
10
4.

using NDDM.

4.5
9
11.75
19.55

given the following set of data using NDDM.

0.5
2.5
5
7.75
11.5

1.125
2.554
7.215
8.0125
13.450

CHAPTER

5
SOLUTIONS TO
ORDINARY DIFFERENTIAL EQUATIONS
An ordinary differential equation or ODE is an equation containing a
function of one independent variable and its derivatives. The term "ordinary" is
used in contrast with the term partial differential equation which may be with
respect to more than one independent variable.
Linear differential equations, which have solutions that can be added
and multiplied by coefficients, are well-defined and understood, and exact
closed-form solutions are obtained. By contrast, ODEs that lack additive
solutions are nonlinear, and solving them is far more intricate, as one can rarely
represent them by elementary functions in closed form: Instead, exact and
analytic solutions of ODEs are in series or integral form.
Numerical methods for ordinary differential equations are methods
used to find numerical approximations to the solutions of ordinary differential
equations (ODEs). Their use is also known as "numerical integration", although
this term is sometimes taken to mean the computation of integrals.
Many differential equations cannot be solved using symbolic
computation ("analysis"). For practical purposes, however such as in
engineering a numeric approximation to the solution is often sufficient. The
algorithms studied here can be used to compute such an approximation. An
alternative method is to use techniques from calculus to obtain a series
expansion of the solution.
A first-order differential equation is an Initial value problem (IVP) of the
form,
(
)

First-order means that only the first derivative of y appears in the


equation, and higher derivatives are absent.
Without loss of generality to higher-order systems, we restrict
ourselves to first order differential equations, because a higher-order ODE can
be converted into a larger system of first-order equations by introducing extra
variables. For example, the second-order equation y'' = y can be rewritten as
two first-order equations: y' = z and z' = y.

5-1 EULERS METHOD


In mathematics and computational science, the Euler method is a SNorder numerical procedure for solving ordinary differential equations (ODEs)
with a given initial value. It is the most basic explicit method for numerical
integration of ordinary differential equations.
Given a differential equation (D.E.) of the form
and an initial
condition
, we would like to a find function
that satisfies the D.E.
and passes through the point
. In some cases, one can identify the
general solution to the D.E. by inspection or using methods such as separation
of variables and integration. But sometimes, either we dont have the analytic
tools in our tool bag to solve the D.E. or an analytic solution is not possible.
Thats when we need a numerical method for solving the D.E. One such method
is Eulers Method. It is based on using tangent lines to piece together an
approximation to the particular solution to the D.E.

Examples
1.

Given the ordinary differential equation y 4y = 16 where y(0) = 5, find


y(2) using Eulers method. (Use x=0.25)
y 4y = 16; y(0) = 5; x=0.25
Solution:
y 4y = 16
y= 16 + 4y
= 16 + 4y
y = (16 + 4y)x

When n=1, Xn=0, Yn=10:


y = (16 + 4y)x
y = (16 + 4y)(0.25)
y = 9
= + y
=5+9
= 14
And so on when n=2
N
0
1
2
3
4
5
6
7
8

0
0.25
0.50
0.75
1.00
1.25
1.50
1.75
2.00

5
14
32
68
140
284
572
1148
2300

x
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.25

y
9
18
36
72
144
288
576
1152
-

14
32
68
140
284
572
1148
2300
-

y(2) = 2300
2.

Given the ordinary differential equation y + 3y = 10 where y(0) = 1, find


y(1.5) using Eulers method. (Use x=0.15)
y + 3y = 10; y(0) = 1; x=0.15
N
0
1
2
3
4
5
6
7
8

0
0.15
0.30
0.45
0.60
0.75
0.90
1.05
1.20

1
3.1
3.205
3.26275
3.294512
3.311981
3.321589
3.326873
3.329780

x
0.15
0.15
0.15
0.15
0.15
0.15
0.15
0.15
0.15

y
2.1
0.105
0.05775
0.031762
0.017469
0.009608
0.005284
0.002907
0.001599

3.1
3.205
3.26275
3.294512
3.311981
3.321589
3.326873
3.329780
3.331379

9
10

1.35
1.50

3.331379
3.332258

0.15
0.15

0.000879
-

3.332258
-

y(1.5) = 3.332258
3.

Given the ordinary differential equation 2y + 5y = 12 where y(0) = 3, find


y(0.4) using Eulers method. (Use x=0.05)
2y + 5y = 12; y(0) = 3; x=0.05
N
0
1
2
3
4
5
6
7
8

0
0.05
0.10
0.15
0.20
0.25
0.30
0.35
0.40

3
2.925
2.859375
2.801954
2.751710
2.707747
2.669279
2.635620
2.606168

x
0.05
0.05
0.05
0.05
0.05
0.05
0.05
0.05
0.05

y
-0.075
-0.065625
-0.057421
-0.050244
-0.043963
-0.038468
-0.033659
-0.029452
-

2.925
2.859375
2.801954
2.751710
2.707747
2.669279
2.635620
2.606168
-

y(0.4) = 2.606168

Exercises
1.
2.
3.
4.
5.

Find y(0.3) of 2xyy = 1+y2 using Eulers Method. (Use y(0) = 2; x =


0.05)
Find y(0.15) of (xy)x + (1 + x2)y = 0 using Eulers Method. (Use y(0) =
2; x = 0.05)
Find y(0.4) of x(x) + y(y) = 0 using Eulers Method. (Use y(0.2) = 4;
x = 0.05)
Find y(0.6) of 2y + 5y = 10 using Eulers Method. (Use y(0) = 1.2; x =
0.1)
Find y(0.24) of 3y + 2y = 4 using Eulers Method. (Use y(0) = 1; x =
0.03)

5-2 RUNGE KUTTA METHOD


RungeKutta methods are an important family of implicit and
explicit iterative methods, which are used in temporal discretization for
the approximation of solutions of ordinary differential equations. These
techniques were developed around 1900 by the German
mathematicians C. Runge and M. W. Kutta.

Examples
1.

Given the IVP


y + 2y = 8

y(0.5)=3.25

= (8 2y)
= 1.5
=0.75
= 1.125
= 0.375
=

= 0.468750

Find y(1) .

n
1
2

0.5
1

3.25
3.71875

0.468750

3.71875

y(1) = 3.718
2.

Given the IVP


y +2x = 0

= (2x

y(o) = 1

h = 0.2

=0
= -0.2
= -0.19208
= .369857
=

= -.038467
= (2x

)
= -0.369818
= -0.512876
= -0.497128
= -0.594583

= -0.099480
= (2x

)
= -0.594508

= -0.644170
= -0.636223
= -0.647932
=

= -0.126774
= (2x

)
= -0.648762
= -0.629215
= -0.632890
= -0.592827

= -0.125526
= (2x

)
= -0.594526
= -0.544738
= -0.554643
= -0.497292

= -0.109686
n
1
2
3
4

0
0.2
0.4
0.6

1
0.961533
0.862053
0.735279

-.038467
-0.099480
-0.126774
-0.125526

0.961533
0.862053
0.735279
0.609573

5
6

0.8
1

0.609573
0.499887

-0.109686

0.499887

y(1) = 0.499

3.
h = 0.1

y =

y(1) = 2.3
y(1.3) = ?
n
1
2
3
4

1
1.1
1.2
1.3

2.3
3.13287
4.761419
9.384592

0.83287
1.628549
4.623173

3.13287
4.761419
9.384592

y(1.3) = 9.384

Exercises
Solve the following using Runge-Kutta Method.
1.

y =
y(0) = 1
h = 0.5 y(3) = ?

2.

y(0.3) = 2
h = 0.05. Find y(0.45).

3.

, y(0) = 2

4.

Find y(0.5) = ?
Find
of

5.

Find

of

if
if

and
and

is .
.

Vous aimerez peut-être aussi