resistor ic design layout
DESCRIPTION
Resistor IC Design layout in L-editTRANSCRIPT
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
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 non-
linear 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
CHAPTER
1
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. Direct methods – In the absence of round off error
such methods would yield the exact solution
within a finite number of steps.
2. 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. The leading coefficient is not in the
same level
C. 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:
inv(A) = )det(
)(adjoint
A
A
adj(A)= T] )( cof [ A
adj(A) = [
]
det(A) = (2)(6) – (5)(4) = -8
inv(A) = [
]
inv(A) = [
]
USING ELEMENTARY ROW OPERATIONS:
A = [
|
|]
= [
|
|]
= [
|
|]
= [
|
|]
= [
|
|]
Therefore,
inv(A) = [
]
2. B =[
]
R1 / 2
R2 - 4 R1
R2 /-4
R1 – 2.5R2
USING ANALYTICAL METHOD:
inv(B) = )det(
)(adjoint
B
B
adj(B) = T] )( cof [ B
adj(B) =
T
72
43
62
03
67
04
85
43
05
03
08
04
85
72
05
62
08
67
=
T
13)18(24
)4(00
19)30(48
adj(B) =
13419
18030
24048
det(B) = [(-3)(7)(0) + (4)(6)(5) + (0)(-2)(8)] -
[(0)(7)(5) + (-3)(6)(8) + (4)(-2)(0)]
det(B) = -24
inv(B) = 24
13419
18030
24048
inv(B) =
5416.01667.07916.0
75.025.1
102
USING ELEMENTARY ROW OPERATIONS:
B =[
|
]
[
|
]
[
||
]
[
||
]
R2 + 2R1
R3 - 5R1
R2 x 3/13
R3 + 4/3R2
R1 /-3
[
||
]
[
||
]
[
||
]
[
|
]
Therefore,
inv(B) =
5416.01667.07916.0
75.025.1
102
I. Solved Examples
INVERSE MATRIX METHOD
inv (A) · Ax = inv (A) · C
R3 x 13/24
R2 – 18/13R3
R1 + 4/3R2
1. Solve the given system of linear equation
using inverse matrix method
Solution:
[
] [
] [
]
A · x = C
For inv(A)
[
|
|]
[
|
|]
[
|
|]
[
|
|]
[
|
|] (inverse of A)
X = [
] [
]
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) · C
x = [
] [ ]
x = [
]
II. Exercises
Solve for the inverse of the following matrices:
1. C =
4317
5364
2589
1253
2. D =
5129
8376
4258
2795
3. E =
9741
2876
3258
2974
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 − x3 = 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
x2= 5
− x3 = -2
Add −2 times Row 2 toRow1.
x1 = -4
x2 = −5
x3= 2
Multiply Rows 2 and 3 by−1.
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
[
|
|
|
]
[
|
|
]
x1 + ½ x2 + ½ x3 + ½ x4 + ½ x5 = 3
x2 + 1/3 x3 + 1/3x4 + 1/3x5 =
x3 + 1/4x4 + 1/4x5 = 27/2
x4 + 1/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
R5 * 5/6
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
system’s augmented matrix to reduced-row echelon form
by means of row operations.
Reduced row-echelon form: (1) each row starts with an initial 1 (0’s to the left of it) (2) each initial 1 is to the right of the one in the row above (3) there are 0’s 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
material—metal, plastic, and rubber—are required for
production. The amounts needed to produce each
component are:
Component
Metal (g/componen
t)
Plastic (g/componen
t)
Rubber (g/componen
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.
Solution:
15x1 + 17x2 + 19x3 = 2120 0.25x1 + 0.33x2 + 0.42x3 = 43.4 x1 + 1.2x2 + 1.6x3 = 164
[
|
]
[
|
]
R1 * 1/15
R3 – R1
R2 – 0.25R1
[
||
]
[
||
]
[
||
]
[
|
]
[
|
]
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
R2 * 150
/7
R1 – 17
/15R2
R3 – 1/15R2
R1 + 87
/70R3
R3 * 70
/13
R2 - 31
/14R3
3. 2x2 + x3 = −8 x1 − 2x2 − 3x3 = 0 −x1 + x2 + 2x3 = 3
4. x + 3y + 5z = 22 2x + 4y +6z = 28 x + 2y + 4z = 17
5. 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
are the kth iterates
Where k = 0, 1, 2 . . .
II. Solved Example
1.
Test for diagonally dominant
[
]
| | | | | || | | | | || | | | | |
Solve for
n X1 X2 X3
0 0 0 0
1 0.666667 3 28
2 0.6 2.1333333 3.266667
3 1.044445 2.033333 3.106667
4 1.024445 1.962221 2.997778
5 1.011852 1.994444 2.987555
6 0.997704 2.000148 2.996518
7 0.998790 2.001445 3.000489
8 0.999691 2.00080 3.000531
9 1.000117 1.999947 3.000100
10 1.000051 1.999946 2.999966
2.
Test for diagonally dominant
[
]
| | | | | || | | | | || | | | | |
Solve for
n X1 X2 X3
0 0 0 0
1 3.148150 4.8 2.037040
2 2.156930 3.269130 1.889850
3 2.491670 3.685250 1.936550
4 2.400930 3.545130 1.922650
5 2.431550 3.583270 1.926920
6 2.423230 3.570460 1.925650
7 2.426030 3.573950 1.926040
8 2.425270 3.572780 1.925930
9 2.425520 3.573100 1.925960
10 2.425460 3.573000 1.925950
3.
Test for diagonally dominant
[
]
| | | | | || | | | | || | | | | |
Solve for
III. Exercises
1.
n X1 X2 X3
0 0 0 0
1 -0.2 0.222222 -0.428571
2 0.146031 0.203174 -0.517460
3 0.191745 0.328394 -0.415873
4 0.180881 0.332345 -0.420700
5 0.185358 0.329260 -0.424369
6 0.186325 0.331160 -0.422649
7 0.186053 0.331294 -0.422641
2.
3.
4.
5.
1-5 GAUSS- SEIDEL METHOD
I. Introduction
In numerical linear algebra, the Gauss–Seidel 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 non-
zero 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 X1 X2 X3
0 0 0 0
1 0.75 2.5 3.145833
2 0.911458 2.004464 3.008494
3 1.001007 1.998498 2.999540
1.
Solve for
2.
Solve for
4 1.000260 1.999991 2.999976
5 0.999996 2.000004 3.000001
n X1 X2 X3
0 0 0 0
1 0.75 1.75 -1
2 0.9375 1.979166 -1.005952
3 0.993303 1.998759 -1.000779
4 0.999495 1.999961 -1.000066
5 0.999973 2.000002 -1.000004
3.
Solve for
n X1 X2 X3
0 0 0 0
1 1.3 1.04 0.936
2 0.9984 1.00672 0.939648
3 0.998691 1.000297 1.000232
4 0.999917 0.999993 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
[
] [
] = [
]
U X = Z
[
] [
] = [
]
[ ]
[ ]
II. Solved Examples
Example 1
Solve the following Linear Equation.
4 + 3 = 1
6 + = 3
A = [
] 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
4 + 2 + = 11
16 + 4 + = 27
A = [
] C = [
]
Solution:
Step 1
[ ] x
= [
]
l21 =
[ ]
[
]
[
] 2nd row
Step 2
[ ] x
= [
]
l31 =
[ ]
[
]
[
] 3rd row
Step 3
[
]
[
] x (-2) =
[
] l32 = -2
[
]
[
]
[
] 3rd row
Step 4
[
] x [
] = [
]
L Z = C
A = [
] C = [
]
[
] x [
]
[
] [
] = [
]
= 18
= 11 -
(18) = 3
= 27 -
(18) + 2(3) = 1
[
]
U X = Z
[
] x [
] = [
]
= [ – – ]
= 1
= [3 -
]
= 2
= 3
x = [ ]
X = [
]
Example 3
Solve the following Linear Equation.
– 0.1 -0.2 = 7.85
+ 7 – 0.3 = -19.3
0.3 – 0.2 + 10 = 71.4
L = [
]
U = [
]
L Z = C
[
] [
] = [
]
z = [
]
U X = Z
[
] [
] = [
]
=
= 6.993
x = [
]
III. Exercises
1. Solve the following linear equation
+ 2 = 6
+ 5 = 10
2. Solve the following linear equation
+ 2 + 3 = 5
- 4 + 6 = 18
3 – 9 - 3 = 6
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 + + = 4
+ 2 + 9 + + 5 = 3
3 + + + 7 + = -5
2 + + 5 + +8 = 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 resulting from the Cholesky
Method Decomposition.
[
] [
] [
]
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.
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
CHAPTER
2
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 a b
0 0 5 2.5 3.25
1 0 2.5 1.25 -1.4375
2 1.25 2.5 1.875 0.515625
3 1.25 1.875 1.5625 -0.55859
4 1.5625 1.875 1.71875 -0.0459
5 1.71875 1.875 1.796875 0.22876
6 1.71875 1.796875 1.757813 0.089905
7 1.71875 1.757813 1.738281 0.021622
8 1.71875 1.738281 1.728516 -0.01223
9 1.728516 1.738281 1.733398 0.00467
10 1.728516 1.733398 1.730957 -0.00379
11 1.730957 1.733398 1.732178 0.00044
12 1.730957 1.732178 1.731567 -0.00167
13 1.731567 1.732178 1.731873 -0.00062
14 1.731873 1.732178 1.732025 -8.9E-05
15 1.732025 1.732178 1.732101 0.000175
1.732 1.732 1.732
Thus, the zero of the function is 1.732.
2. Find the zero of the function for the interval [2,5]
Solution,
iterations a b
0 2 5 3.5 0.013753
1 2 3.5 2.75 -0.26675
2 2.75 3.5 3.125 -0.13175
3 3.125 3.5 3.3125 -0.06036
4 3.3125 3.5 3.40625 -0.02365
5 3.40625 3.5 3.453125 -0.00504
6 3.453125 3.5 3.476563 0.004335
7 3.453125 3.476563 3.464844 -0.00036
8 3.464844 3.476563 3.470703 0.001988
9 3.464844 3.470703 3.467773 0.000815
10 3.464844 3.467773 3.466309 0.000229
11 3.464844 3.466309 3.465576 -6.4E-05
12 3.465576 3.466309 3.465942 8.26E-05
13 3.465576 3.465942 3.465759 9.35E-06
3.466 3.466 3.466
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 a b
0 0.5 1.5 1 0.283662
1 0.5 1 0.75 -0.82056
2 0.75 1 0.875 -0.33102
3 0.875 1 0.9375 -0.02489
4 0.9375 1 0.96875 0.130984
5 0.9375 0.96875 0.953125 0.053211
6 0.9375 0.953125 0.945313 0.014173
7 0.9375 0.945313 0.941406 -0.00536
8 0.941406 0.945313 0.943359 0.004408
9 0.941406 0.943359 0.942383 -0.00047
10 0.942383 0.943359 0.942871 0.001966
11 0.942383 0.942871 0.942627 0.000746
12 0.942383 0.942627 0.942505 0.000135
0.942 0.943 0.943
Thus, the zero of the function is 0.943.
Exercises
Find the root of the following functions using bisection method.
1. y=3x^3+2x+1 for interval [-1,0]
2. y=x^2-6 for interval [0,5]
3. y=3x^2+2/3 for interval [0,1]
4. y=tan^(-1)〖(x)〗-1 for interval [0,5]
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 real-
valued function.
The Newton–Raphson 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 5 15 35 4.571429
1 4.571429 1.941702 26.122457 4.497098
2 4.497098 0.053255 24.694887 4.494941
3 4.494941 0.000032 24.653955 4.494939
x = 4.4949 No. of iterations: 3
2.
Given:
n
0 0 2 -3 0.666666
1 0.666666 -0.142739 -3.626358 0.627304
2 0.627304 -0.001342 -3.558592 0.626926
3 0.626926 0.000002 -3.557956 0.626926
x = 0.6269 No. of iterations: 3
3.
Given:
n
0 2 -1 12 2.083333
1 2.083333 -0.287134 5.440439 2.136110
2 2.136110 -0.083472 2.447966 2.170208
3 2.170208 -0.024438 1.096577 2.192493
4 2.192493 -0.007186 0.489879 2.207161
5 2.207161 -0.002118 0.218468 2.216855
6 2.216855 -0.000626 0.097357 2.223284
7 2.223284 -0.000185 0.043353 2.227551
8 2.227551 -0.000054 0.019316 2.230346
9 2.230346 -0.000016 0.008740 2.232176
10 2.232176 -0.000005 0.004050 2.233410
11 2.233410 -0.000001 0.001891 2.233938
12 2.233938 -0.0000008 0.001215 2.234596
13 2.234596 -0.0000002 0.000580 2.234940
x = 2.234 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, using Secant Method.
Assume and
n
1 5 10 -24 26 7.4
2 10 7.4 26 -6.24 7.903225
3 7.4 7.903225 -6.24 -1.055159 8.005635
4 7.903225 8.005635 -1.055159 0.062016 7.999950
5 8.005635 7.999950 0.062016 -0.000549 7.999999
Iteration = 4 answer=8
2. Given the function find the root using Secant method.
Assume and
n
1 3 4 -6.914463 6.598150 3. 511704
2 4 3. 511704 6.598150 -3.490882 3.680658
3 3. 511704 3.680658 -3.490882 -0.969239 3.745598
4 3.680658 3.745598 -0.969239 0.245802 3.732460
5 3.745598 3.732460 0.245802 -0.012007 3.733071
6. 3.732460 3.733071 -0.012007 -0.000155 3.733078
Iteration = 5 answer = 3.733
3. Given the function – find the root using Secant method.
Assume and
n
1 0 1 -1 1.559752 0.390662
2 1 0.390662 1.559752 -0.141240 0.441257
3 0.390662 0.441257 -0.141240 -0.018263 0.448770
4 0.441257 0.448770 -0.018263 0.000242 0.448671
Iteration = 3 answer = 0.449
Exercises
1. Find a root of – x – 10; Assume and 2. Find a root of - = 1; Assume and 3. Find a root of ln(x) – 2 = 0; Assume and 4. Find a root of x-sin[x]-(1/2) = 0; Assume and 5. 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) = 52 – 5(5) – 24
= -24
f(b) = f(10) = 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 a b f(a) f(b) c f(c) f(a)*f(c)
1 5 10 -24 26 7.4 -6.24 +
2 7.4 10 -6.24 26 7.903225 -1.055159 +
3 7.903225 10 -1.055159 26 7.984999 -0.164785 +
4 7.984999 10 -0.164785 26 7.997689 -0.025415 +
5 7.997689 10 -0.025415 26 7.999644 -0.003915 +
6 7.999644 10 -0.003915 26 7.999945 -0.000604 +
x = 8
2. Given the function f(x) = x3 + 3x − 5 find the root using Regula Falsi
Method.
f(x) = x3 + 3x − 5 , [ 1 ,2 ]
n a b f(a) f(b) c f(c) f(a)*f(c)
1 1 2 -1 9 1.1 -0.369 +
2 1.1 2 -0.369 9 1.135446 -0.129802 +
3 1.135446 2 -0.129802 9 1.147737 -0.044874 +
4 1.147737 2 -0.044874 9 1.151965 -0.015420 +
5 1.151965 2 -0.015420 9 1.153415 -0.005290 +
6 1.153415 2 -0.005290 9 1.153912 -0.001815 +
7 1.153912 2 -0.001815 9 1.154082 -0.000626 +
x = 1.154
3. Given the function f(x) = ex − 3x2 find the root using Regula Falsi
Method. f(x) = ex − 3x2 , [ 3 , 4 ]
n a b f(a) f(b) c f(c) f(a)*f(c)
1 3 4 -6.914463 6.598150 3.511704 -3.490882 +
2 3.511704 4 -3.490882 6.598150 3.680658 -0.969239 +
3 3.680658 4 -0.969239 6.598150 3.721559 -0.221228 +
4 3.721559 4 -0.221228 6.598150 3.730591 -0.048179 +
5 3.730591 4 -0.048179 6.598150 3.732543 -0.010398 +
6 3.732543 4 -0.010398 6.598150 3.732963 -0.002251 +
7 3.732963 4 -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
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 when x is equal to . Use analytical and numerical method. Solution: Analytical Method
CHAPTER
3
-23.141
Solution: Numerical Method
-23.141
2. Determine the derivatives of when x = 5. Use
numerical method.
2.609
3. Using numerical differentiation, determine if
x = 4. Let h = 0.0001 for more accurate result.
-0.6536
III. Exercises
1. Determine the derivatives of
when x = 0.5. Compare
with analytical method. 2. Find f’(3) : . 3. Determine the derivatives of when x = 0.8.
Compare with analytical method.
4. Determine the derivatives of √ when x = 8. 5. Find f’’(x) :
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 + 2∆x, . . . , xn = a + n∆x = 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 (xi−1, yi−1) 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)]
I≈
[-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 f(x)
2 -4
2.5 -4.25
3 -4
3.5 -3.25
4 -2
3. Approximate the integral of f(x) = 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 F(x)
1 -5.281
1.25 -4.759
1.5 -4.018
1.75 -2.995
2 -1.61
III. EXAMPLES
1. Using , approximate the value of
2. Numerically approximate the
integral by using the trapezoidal rule with n = 8 subintervals.
3. Numerically approximate the integral by
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 2.1 2.4 2.7 3.0 3.3 3.6
y 3.2 2.7 2.9 3.5 4.1 5.2
Use the trapezoidal rule to estimate∫
3.2.b. Simpson’s Rule
Simpson’s 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 Simpson’s 1/3 rule for integration was derived by approximating the
integrand )(xf with a 2nd order (quadratic) polynomial function )(2 xf where
2
2102 )( xaxaaxf .
)(~
xf Cubic function.
Simpson 3/8 rule for integration can be derived by approximating the
given function )(xf with the 3rd order (cubic) polynomial )(3 xf .
3
2
1
0
32
3
3
2
2103
,,,1
)(
a
a
a
a
xxx
xaxaxaaxf
The unknown coefficients 3210 and,, aaaa can be obtained by
substituting 4 known coordinate data points
},{and},{},,{},,{ 33221100 xfxxfxxfxxfx .
2
33
2
323103
2
23
2
222102
2
13
2
121101
2
03
2
020100
)(
)(
)(
)(
xaxaxaaxf
xaxaxaaxf
xaxaxaaxf
xaxaxaaxf
where:
Substituting the form of xf3 from this method.
b
a
b
a
dxxf
dxxfI
`3
8
33 3210 xfxfxfxfab
Since
3
abh
, then hab 3
The simplified equation will be
3210 338
3xfxfxfxf
hI
For multiple segments for Simpson’s 3/8 rule, where n = number of
equal segments, the width h can be defined as
n
abh
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
b
a
b
a
dxxf
dxxfI
3
bx
x
x
x
x
ax
n
n
dxxfdxxfdxxf
3
6
3
3
0
333 ........
Using Simpson 3/8 rule, one gets
nnnn xfxfxfxf
xfxfxfxfxfxfxfxfhI
123
65433210
33.....
3333
8
3
n
n
i
i
n
i
i
n
i
i xfxfxfxfxfh 3
,..9,6,3
1
,..8,5,2
2
,..7,4,1
0 2338
3
Simpson’s 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 0.5
1 1.111111 0.447513
2 1.222222 0.40099
3 1.333333 0.36
4 1.444444 0.324
5 1.555555 0.292418
6 1.666666 0.264705
7 1.777777 0.240356
8 1.888888 0.218918
9 2 0.2
∫
[ ∑[ ]
∑
( )
]
(
)
[
]
I 0.3217497917
I
2. Approximate I=∫
with h=0.2
Solution :
0 0 1
1 0.2 0.818730
2 0.4 0.670320
3 0.6 0.548811
4 0.8 0.449328
5 1 0.367879
6 1.2 0.301194
∫
[ ∑[ ]
∑
( )
]
[
]
I 0.698819025
I
3. Approximate l=∫
Solution:
0 0 0
1 0.342020
2 0.642787
3 0.866025
4 0.984807
5 0.984807
6 0.866025
7 0.642787
8 /9 0.342020
9 0
∫
[ ∑[ ]
∑
( )
]
(
)
[
]
I 2.000380848
I
EXERCISES
1. Numerically approximate the integral by using Simpson's 3/8 rule with m = 10, 20, 40, 80, and 160.
2. Determine the integral of the function
by Simpson’s 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 8x to 30x
seconds is given by
30
8
8.92100140000
140000ln2000 dxx
ts
Use Simpson 3/8 rule to find the approximate value of the integral.
4. Use Simpson’s rule with n = 6 to estimate ∫ √
5. Find ∫
with n = 9 using analytical and numerical
method.
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.
CHAPTER
4
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. Given the set of data below, determine:
a. The linear regression
b. y(8)
x y
1 1
2 2
3 1.3
4 3.75
5 2.25
a.
√
√
[ ] [ ]
√[ ][
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:
a. Identify the 8th term
b. Calculate what term does 25 occur
x y
1 1
2 4
3 7
4 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 y
0 2
1 3
2 5
3 4
4 6
Exercises
1. Given the following data, find y(18).
2. Given the following data, find the linear
regression.
3. Given the following data, find the value of x that will make y equal to
200.
x y
0 12
1 19
2 29
3 37
4 45
x y
-2 -1
1 1
3 2
x y
32 0
68 20
86 30
122 50
4. Given the following data, find the linear regression.
5. Given the following data, find the linear regression.
158 70
194 90
212 100
x y
-1 0
0 2
1 4
2 5
x y
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 + … + ajx
j = 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 + … + ajx
j ))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 =
[
∑ ∑ ∑
∑ ∑ ∑
∑
∑ ∑
∑ ∑
∑
∑ ∑
∑ ]
, X=
[
]
, B=
[
∑
∑
∑
∑
]
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 1 2 3 4 5 6
x 0 0.5 1.0 1.5 2.0 2.5
y 0 .25 1.0 2.25 4.0 6.25
Since the order is 2 (j =2), the matrix form to solve is
[
∑ ∑
∑ ∑ ∑
∑ ∑
∑
] [
] = [
∑
∑
∑
]
n=6 ∑xi = 7.5 ∑yi = 13.75 ∑x2
i = 13.75 ∑xi yi = 28.125 ∑x3
i = 28.125 ∑x2i yi = 61.1875
∑x4i = 61.1875
[
] [
] = [
]
Note: we are using ∑x2
i, NOT (∑xi )2. There’s 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
2. Fit a second- order polynomial to the data
i 1 2 3 4 5 6
x 0 1 2 3 4 5
y 2.1 7.7 13.6 27.2 40.9 61.1
∑xi = 15 ∑x4i = 979
n = 6 ∑yi = 152.6 ∑xi yi = 585.6 x = 2.5 ∑x2
i = 55 ∑x2i yi = 2488.8
y = 25.433 ∑x3i = 225
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= [ 0 1 2 3 4 6 ];
y= [ 2.1 7.7 13.6 27.2 40.9 80.3 ];
The result is
[
] = [
] f(x) = + *x + *x2
f(x) = + x + x2
Exercises
1. Fit a second- order polynomial to the data
x = [0 0 1 1.5 2 2.5] y = [0.0674 -0.9156 1.6253 3.0377 3.3535 7.9409]
2. Fit a second order polynomial to the data
I 1 2 3 4 5 6
T (˚F) 80 40 -40 -120 -200 -280
α (µin/in/˚F) 6.47 6.24 5.72 5.09 4.30 3.33 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 1 2 3 4 5 6
Time (s) 0 0.5 1 1.5 2 2.5
Height(ft) 0 20.5 31.36 36.25 30.41 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 2 3 4 5
Year 1976 7980 1987 1993 1998
Cost (per person)
618 860 1324 1865 2256
Hint: x0=1970. 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 Y
2 4
4 8
6 12
8 16
Using linear interpolation, determine x (10).
Solution:
)
2. Given the following data:
x Y
5 25
10 35
15 45
20 Y
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 y
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. Find values of ρ at
(a) T = 210
(b) 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:
There are no restrictions for the values of y0, y1, and y2. To find out the
value of to an arbitrary point , use the formula:
Examples
1. Find the value of using Quadratic Interpolation. Given the
following data:
x 0 10 15 20 22.5 30
f(x) 0 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 0 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
Compare your estimate with the value of given by your calculator.
Solution:
Use the formula (a)
Substitute 0.5 and 0.6 to (a)
For 0.5,
For 0.6,
x 0.5 0.6 0.7
f(x) 0.47943 0.56464 0.64421
For 0.7,
Therefore,
Substitute the values obtained to (a)
By calculator
Exercises
1. Given the data below, find using Quadratic Interpolation.
x 0.564 2.9 4.5 5.3 7.65
f(x) 4.573 7 14.87 16.12 20.76
2. Find using Quadratic Interpolation, given the following data
x 0.045 0.098 0.15 0.29 0.32
f(x) 0.581 0.862 0.367 0.738 0.912
3. Find f(-2.5) using Quadratic Interpolation, given the following data
x -4.17 -3.49 -1.52 -0.98 1.23 2.75
f(x) -15.28 -9.72 -4.89 -1.60 2.69 5.43
4. Given the data below, find using Quadratic Interpolation.
x 7 10 15 20
f(x) 14 26.5 32.8 52
5. Given the data below, find using Quadratic Interpolation.
x 13.46 23.79 32.94 40.12
f(x) 18.90 31.2 49.32 60.31
4-5 NEWTON’S 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 b c
Xa Xb Xc
Let’s 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 using NDDM.
0 1
1 3
3 49
4 129
7 813
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 1
0.5 1.8987
1 3.7183
2 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 using NDDM.
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] =
0 0
1 1.18
3 10.7
5 25.8
7 63.2
10 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 using NDDM.
0 1.5
2 2.5
4 7
6 11
2. Given the following set of data, find using NDDM.
3. Determine given the following set of data using NDDM.
0 4.5
5 9
7 11.75
10 19.55
4. Determine given the following set of data using NDDM.
0 4.5
5 9
7 11.75
10 19.55
5. Determine given the following set of data using NDDM.
0.5 1.125
2.5 2.554
5 7.215
7.75 8.0125
11.5 13.450
0 1.5
2 2.5
4 7
6 11
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,
( )
CHAPTER
5
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 EULER’S METHOD
In mathematics and computational science, the Euler method is a SN-order 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 don’t have the analytic tools in our tool bag to solve the D.E. or an analytic solution is not possible. That’s when we need a numerical method for solving the D.E. One such method is Euler’s 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 Euler’s 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 Δx Δy
0 0 5 0.25 9 14
1 0.25 14 0.25 18 32
2 0.50 32 0.25 36 68
3 0.75 68 0.25 72 140
4 1.00 140 0.25 144 284
5 1.25 284 0.25 288 572
6 1.50 572 0.25 576 1148
7 1.75 1148 0.25 1152 2300
8 2.00 2300 0.25 - -
y(2) = 2300
2. Given the ordinary differential equation y’ + 3y = 10 where y(0) = 1, find
y(1.5) using Euler’s method. (Use ∆x=0.15) y’ + 3y = 10; y(0) = 1; ∆x=0.15
N Δx Δy
0 0 1 0.15 2.1 3.1
1 0.15 3.1 0.15 0.105 3.205
2 0.30 3.205 0.15 0.05775 3.26275
3 0.45 3.26275 0.15 0.031762 3.294512
4 0.60 3.294512 0.15 0.017469 3.311981
5 0.75 3.311981 0.15 0.009608 3.321589
6 0.90 3.321589 0.15 0.005284 3.326873
7 1.05 3.326873 0.15 0.002907 3.329780
8 1.20 3.329780 0.15 0.001599 3.331379
9 1.35 3.331379 0.15 0.000879 3.332258
10 1.50 3.332258 0.15 - -
y(1.5) = 3.332258
3. Given the ordinary differential equation 2y’ + 5y = 12 where y(0) = 3, find
y(0.4) using Euler’s method. (Use ∆x=0.05)
2y’ + 5y = 12; y(0) = 3; ∆x=0.05
N Δx Δy
0 0 3 0.05 -0.075 2.925
1 0.05 2.925 0.05 -0.065625 2.859375
2 0.10 2.859375 0.05 -0.057421 2.801954
3 0.15 2.801954 0.05 -0.050244 2.751710
4 0.20 2.751710 0.05 -0.043963 2.707747
5 0.25 2.707747 0.05 -0.038468 2.669279
6 0.30 2.669279 0.05 -0.033659 2.635620
7 0.35 2.635620 0.05 -0.029452 2.606168
8 0.40 2.606168 0.05 - -
y(0.4) = 2.606168
Exercises
1. Find y(0.3) of 2xyy’ = 1+y2 using Euler’s Method. (Use y(0) = 2; ∆x = 0.05)
2. Find y(0.15) of (xy)∆x + (1 + x2)∆y = 0 using Euler’s Method. (Use y(0) = 2; ∆x = 0.05)
3. Find y(0.4) of x(∆x) + y(∆y) = 0 using Euler’s Method. (Use y(0.2) = 4; ∆x = 0.05)
4. Find y(0.6) of 2y’ + 5y = 10 using Euler’s Method. (Use y(0) = 1.2; ∆x = 0.1)
5. Find y(0.24) of 3y’ + 2y = 4 using Euler’s Method. (Use y(0) = 1; ∆x = 0.03)
5-2 RUNGE – KUTTA METHOD
Runge–Kutta 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 ; Find y(1) .
= (8 – 2y) = 1.5
=0.75
= 1.125
= 0.375
=
= 0.468750
n
1 0.5 3.25 0.468750 3.71875
2 1 3.71875
y(1) = 3.718 2. Given the IVP
y’ +2x = 0 y(o) = 1 h = 0.2
= (–2x ) = 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 0 1 -.038467 0.961533
2 0.2 0.961533 -0.099480 0.862053
3 0.4 0.862053 -0.126774 0.735279
4 0.6 0.735279 -0.125526 0.609573
5 0.8 0.609573 -0.109686 0.499887
6 1 0.499887
y(1) = 0.499
3. y’ = + y(1) = 2.3 h = 0.1 y(1.3) = ?
n
1 1 2.3 0.83287 3.13287
2 1.1 3.13287 1.628549 4.761419
3 1.2 4.761419 4.623173 9.384592
4 1.3 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
Find y(0.5) = ?
4. Find of
if and is
.
5. Find of
if and .