mathematics and computation
TRANSCRIPT
-
8/9/2019 Mathematics and Computation
1/47
Basic Mathematics
MSc Petroleum Engineering
University of UMSA
La Paz
April 08-26, 2013
Mesfin BelaynehUoS, Norway
-
8/9/2019 Mathematics and Computation
2/47
Contents1 INTRODUCTION ................................................................................................................... 3
2 VECTOR ALGEBRA ............................................................................................................. 4
2.1 Addition of vectors ......................................................................................................... 4
2.2 Multiplication by a scalar ............................................................................................... 4
2.3 Resolving vectors into components ................................................................................ 5
2.4 Dot product ..................................................................................................................... 7
2.5 Cross product .................................................................................................................. 8
3 MATRIX ALGEBRA ........................................................................................................... 15
3.1 Properties of matrices ................................................................................................... 15
3.2 Procedure to solve simultaneous equation with a matrix system ................................. 20
3.3 Determinants ................................................................................................................ 21
3.4 Minors and Cofactors ................................................................................................... 21
3.5 Adjoint matrix .............................................................................................................. 23
3.6 Inverse matrix ............................................................................................................... 23
4 MODELING VIA DIFFERENTIAL EQUATIONS ............................................................ 26
4.1 First order differential equation .................................................................................... 26
4.2 Second order equations and systems ............................................................................ 30 4.3 Numerical solution methods ......................................................................................... 33
4.3.1 Newton-Raphons non-linear root finding ........................................................ 33
4.3.2 Numerical intergration ..................................................................................... 36 4.3.2.1 Simpson ............................................................................................................. 36
4.3.2.2 Trapezium rule ................................................................................................... 37
4.3.3 Numerical differentiation ................................................................................. 39 4.3.3.1 Numerical Eulers solution methods .................................................................. 39
4.3.4 Curve fitting ..................................................................................................... 44 4.3.4.1 Linear , polynomical, exponential and power .................................................. 44
-
8/9/2019 Mathematics and Computation
3/47
1 Introduction
All fields of studies (Science and Engineering) use mathematics. The language ofmathematics is a tool to formulate theories based on experimental observations. Therefore, inthis section we will learn the basic of mathematics along with the applications. The topics to
be reviewed are:
Vectors (Dot product Determinants; cross product), Matrices; inverse matrices and determinant Finally modeling based on differential equation and solution methods
This will refresh students knowledge of the basic mathematical tools
-
8/9/2019 Mathematics and Computation
4/47
2 Vector algebra
A vector is used to represents a physical quantity that has both a direction and magnitude, forexample, displacement and force. A vector is generally represented by the symbols
U or U
On a diagram, it is generally represented by an arrow. The direction of the arrow represents itsdirection and the length represents its magnitude.
2.1 Addition of vectors
The parallelogram rule shows how the sum of two vectors can be obtained graphically. Itdemonstrates that the sum of two vectors is independent of the order in which the vectors areadded. These rules also lead to the following principles:
Commutative law: U + V = V + U
Associative law: (U + V) + W = U + (V + W)
U + V = V + U = W Fig. 1 Parallelogram rule
2.2 Multiplication by a scalar
The product of a scalar p and a vector U can be written as p U. It follows that:
p(q U) = (pq) U (p + q) U = p U + q U p(U + V ) = p U + p V
A vector - U is called "the negative of the vector U" and it has the same magnitude as vector U
but its direction is in the opposite direction.
UV
V
U
W
-
8/9/2019 Mathematics and Computation
5/47
U
A vector U
2U
Multiplication of U with scalar
-U
Negative of the vector U
Fig. 2 Multiplication rule
2.3 Resolving vectors into components
For two dimensions, we can resolve a vector U into vector components Uxand Uy, which are parallel to the x and y axis, respectively. The vector components, Ux and Uy can be expressedas a product of their magnitude and unit vectors, i and j .
U = U xi and Uy j
Similarly, in three dimensional system, we can write
U = U xi + Uy j + Uzk
where i, j and k are the unit vectors defined to point in the positive direction of the x,y and z
axis.
The magnitude for the three dimensional vector is
2z
2y
2x UUUU
Fig. 3: Resolving vectors
Example: Force Vector Characteristics
Since a force can be represented as a vector, we can use the previous vector concepts to helpsolve static problems with multiple forces. Force is a vector quantity, having both magnitudeand direction. When there are several forces acting on a body, these forces can be grouped
and referred upon as a force system. The body is said to be in equilibrium when the appliedforces produces no external effects .
Ux=Uxi
Uy=Uy j
U=Uxi +Uy j
-
8/9/2019 Mathematics and Computation
6/47
When there are two concurrent forces applied to a body a single resultant force can be used torepresent the two forces by applying the addition law for vectors (i.e. parallelogram law). Theuse of trigonometry based on the law of sine and cosine can also be helpful in solving
problems involving two force vectors.
Law of sines:
sinc
sin b
sina
Law of cosine:
cosac2ca b 222
Fig. 4 Law of sines and cosine
However, if there are more than two forces present, the standard method to solve a problem isreduce each vector into its rectangular components so that it they are easy to add and subtract.
A force can be resolved into its rectangular components in the x and y axis as shown in thefigure on the left. The resolved force can be written in Cartesian form:
F = F xi + F y j
F = Fcos i + Fsin j
2y
2x FFF
A force that is resolved (decomposed) into its rectangular components in the x, y, and z-axiscan be expressed in the following Cartesian form:
F = F xi + F y j + F zk
F = Fcos xi + Fcos y j + Fcos zk
2z
2y
2x FFFF
a
b
c
A
C
B
-
8/9/2019 Mathematics and Computation
7/47
Fig. 5 The resolved force in Cartesian form
2.4 Dot product
The dot product of two vectors U and V is defined to be the product of the magnitude of U
and V and the cosine of the angle between them.
U . V = |U| |V| Cos
The dot product can also be calculated by multiplying the x, y and z terms together as:
U . V = (Uxi + Uy j + Uzk) (Vxi + Vy j + Vzk)
U = UxVx + UyVy + UzVz
Dot product has the following properties:
Commutative law: U . V = V . U Associative law: q( U . V) = (q U) . V = U . (qV) Distributive law: U .(V + W ) = U . V + U . W
U . V = |U| |V| cos
Fig. 6 Dot product of U and V
-
8/9/2019 Mathematics and Computation
8/47
Figure 7 Example work done by a force at an angle
W= F 1 .S +F 2
.S = |F 1| |S| cos +|F 2| |S| cos
2.5 Cross product
Let W be the cross product of two vectors U and V such that U x V = W . We define W tohave the following properties:
W points in a direction perpendicular to the plane containing U and V as determined by the right hand rule.
The magnitude of W , |W| = U V sin
Fig. 8 the right hand rule of vector
U x V = W V x U = -W
In general, cross products have the following properties:
Does not follow the commutative law:
S
F1
F2
-
8/9/2019 Mathematics and Computation
9/47
U x V = -( V x U)
Satisfies associative law:
q(U x V) = (q U) x V = U x (q V)
Satisfies distributive law:
U x ( V + W ) = U x V + U x W
Example: Vector Representation of a Moment
When an arbitrarily-shaped body is acted upon by a force, there exists a tendency for theforce to rotate the body about a point or axis. This tendency is known as a moment. The pointor axis about which the rotation takes place is referred to as the moment center. Moments areusually described with reference to a point or axis on the body.
The magnitude of a moment, M, can be described as the product of the perpendiculardistance, d, measured from the point or axis where the force is applied. The perpendiculardistance is also known as the moment arm.
In practice, the moment is considered to be positive if the resultant rotation iscounterclockwise. Negative moments generate clockwise rotation. A moment is a vectorquantity, having both magnitude and direction.
Referring to the figure shown on the left, the moment about point O caused by the appliedforce F , can be described by the cross product of the distance vector, r , and the force vector,F .
Mo = r x F
= r F sin 0 180 0
Mo=dFThe direction of the rotation can be determined using the Right Hand Rule
dF
F
d Moment = Fd
-
8/9/2019 Mathematics and Computation
10/47
2.5.1 Cross Products of Unit Vectors in Cartesian coordinate system
The cross product of unit directional vectors, i, j , and k , can be written as:
i x i = 0 i x j = k i x k = - j
j x i = -k j x j = 0 j x k = i
k x i = j k x j = - i k x k = 0
For a vector U = U xi + U y j + U zk and a vector V = V xi + V y j + V zk , the determinant of U andV can be written as:
zyx
zyx
VVV
UUU
k ji
UxV
Fig. 9 The cross product of unit directional vectors
2.5.2 Moment about a Point
The force applied at point 2 generates a moment about point 1. This moment can also be
calculated using the formula:
Mo = r x F
In this case r calculated in this manner:
r = r 2-r 1
= (x 2 - x1)i + (y 2 - y1) j + (z 2 - z1)k
-
8/9/2019 Mathematics and Computation
11/47
Fig. 10: The force applied at point 2 generates a moment about point 1
In a two dimensional case, there are no components in the k direction. The force and vector r are given in the following:
r = r xi + r y j
F = F xi + F y j
Mo = r x F
0FF0r r
k ji
rxFM
yx
yxo
= (r xFy - r yFx)k
= M zk
Fig. 11: The two dimensional force
-
8/9/2019 Mathematics and Computation
12/47
For a three dimensional case, there are three vector components.
zyx
zyxo
FFF
r r r
k ji
rxFM
= (r yFz - r zFy)i + (r zFx - r xFz) j + (r xFy - r yFx)k
= M xi + M y j + M zk
Fig. 12: Three vector components.
The following is an alternative way of presenting moments in the x, y, and z-axis.
Mx = Mcos
My = Mcos
Mz = Mcos
The magnitudes of the moments are:
Fig. 13 The magnitude of the moments
-
8/9/2019 Mathematics and Computation
13/47
Example: Moment and Force Equilibrium
A body or an object is said to be in equilibrium when the resultant moment and force vectorsare equal to zero.
Fx = 0 Fy = 0 Fz = 0
Mx = 0 My = 0 Mz = 0Example 1
Determine the moments about point O caused by the two applied forces.
X and Y components of the applied forces:
150 N Force:
Fx = 150 cos 45o = 106.1 N
Fy = 150 sin 45o = 106.1 N
250 N Force:
Fx = -250 sin 70 o = -234.9 N
Fy = 250 cos 70o = 85.51 N
Applied forces in Cartesian vector form:
F150 N = (106.1 i + 106.1 j )
F250 N = (-234.9 i + 85.51 j )
Position vector of point 1 and 2 relative to point O in Cartesian form:
r 1/O= (5.00 i + 10.00 j ) m
r 2/O= (-5.00 i + 10.00 j ) m
Using the following equation:
-
8/9/2019 Mathematics and Computation
14/47
0FF
0r r
k ji
rxFM
yx
yxo
= (rxFy - ryFx)k
= Mzk
MO1= [(5.00)(106.1) - (10.00)(106.1)] k= -530.4 k Nm= 530.4 Nm (clockwise)MO2= [(-5.00)(85.51) - (10.00)(234.9)] k
= -2777 k Nm= 2777 Nm (clockwise)
Example 2
Determine the moment about point A induced by the applied force of 1000 lb.
Applied force in Cartesian form:
F = 152 i + 531 j + 834 k
Position vector of point A relative to the origin:r O/A = 500 i + 700 j - 150 k
Using the following equation:
zyx
zyxo
FFF
r r r
k ji
rxFM
= (r yFz - r zFy)i + (r zFx - r xFz) j + (r xFy - r yFx)k
= M xi + M y j + M zk
MAO = [(700)(834) - (-150)(531) i .+ (-150)(152) - (500)(834) j + (500)(531) - (700)(152) k ]lb.in.
MAO = (663.5x103i - 439.8x10 3 j + 159.1x10 3k ) lb-in.
-
8/9/2019 Mathematics and Computation
15/47
3 Matrix algebra
In mathematics we have many ways of expressing numbers and each method use its own rulesof manipulation (algebra). For example, vector algebra is quite different but logical and veryuseful in the solution of problems. Matrix theory is another tool that helps us to solve
problems of a particular kind in Engineering and Science and it is also linked to vector theory.The theory is quite difficult to understand and the rules used to manipulate a matrix are quitecomplex. It will help if you have studied vector theory. In order to fully understand matrixtheory, you will need to have studies to quite an advanced level. This section is only a
beginning.
In this section you will be introduced to some of the basics terms and operations that we can perform with them. We shall also look at more advanced ideas and how they are used to solvesimultaneous equations
On the completion of this chapter, you should be able to do the following Explain the general method for solving system of equations Calculate determinants Calculate minor and cofactors Define and form the adjoint matrix Define and form the inverse matrix Solve system of equations
3.1 Properties of matrices
2.1.1 Matrix description
A matrix is an array of numbers or elements arranged in columns and rows. Each element isdesignated by a letter followed a row and column as shown. The matrix shown might belabeled as A and all the elements as a.
The size of the array is always stated as:
The number of rows x number of columnsThe one shown here is a 3x3 matrix
Columns
1 2 3
-
8/9/2019 Mathematics and Computation
16/47
3.1.2 Transposed matrix
This is a matrix in which row 1 becomes column 1; row 2 becomes column 2 and so on. Thetranspose of matrix A is designated as A T. An example is shown below.
3
84
7
52
A384
752A T
Note that the transpose of a unit matrix is still a unit matrix
3.1.3 Adding and subtracting matrices
Consider how we add two similar equations (2x+3y+5z) + (3x+4y-2z). We arrange them sothe variables line up in columns and then add the coefficients.
2x+3y+5z3x+4y-2z
Add 5x+7y+3z
To show this a matrix operation we would write the following. In other words we simply addor subtract the elements in the same position in each array. So it follows that the arrays must
be the same size.
zy
x
275zy
x
243zy
x
432
We add and subtract two matrices, we dont need to write in the column vector as it is thesame for each part so we only need to write
275243432
Example
Add and subtract the two arrays as shown
-
8/9/2019 Mathematics and Computation
17/47
3.1.4 Multiplication
Scalar
If an equation is multiplied by a constant (scalar) every coefficient will be multiplied by that
constant so a matrix may be easily multiplied or divided by a scalar
333231
232221
131211
333231
232221
131211
aaaaaaaaa
aaaaaaaaa
Vector
Now we will consider how to multiply a matrix by a column vector X to obtain a column
vector b. We are trying to find AX = b.
We want the result to be three equations
a11x+a 12y+a 13z =b 1
a22x+a 22y+a 23z =b 2
a31x+a 32y+a 33z =b 3
It follows that the rule is
(column 1 of A) x (row 1 of X)
(column 2 of A) x (row 2 of X)
(column 3 of A) x (row 3 of X)
It will be seen next that this is a special case of multiplication of arrays in general. For twoarrays the rule is more complex.
Column vectors
X b
A=
-
8/9/2019 Mathematics and Computation
18/47
Array multiplication
Consider how we multiply an array A by another B to obtain a new array C
2221
1211
aa
aa
A
2221
1211
b b
b b
B
2221
1211
cc
cc
CAB
Each element in C is obtained as follows
2222122122
2122112121
2212121112
2112111111
ba bac ba bac ba bac ba bac
This is the general rule. Note that a row x column produces a row. For element c 11 , take thefirst row of A and multiply by the first column of B
2112111121
111211 ba ba b
baa
For element c 12, take the first row of A and multiply by the second column of B
2212121122
121211 ba ba b
baa
For element c 21, take the second row of A and multiply by the first column of B
2122112121
112221 ba ba b
baa
For element c 22, take the second row of A and multiply by the second column of B
2222122122
122221 ba ba b
baa
Collecting all
2222122121221121
2212121121121111
ba ba ba ba
ba ba ba baC
The rule may be summarized as follows and extended to larger arrays
-
8/9/2019 Mathematics and Computation
19/47
2.xCol2.Row1.xCol2.Row
2.xCol1.Row1.xCol1.RowC
Other rules
It can be shown that the normal rules of multiplication may be observed if the orders ofmatrices A, B, C are mentioned on the left side of the equality sign
A(BC) = (AB)C
(A+B)C = AC+BC
A(B+C)= AB+AC
It can also be shown that (AB) T= B TAT
Example: Consider the matrices
01
10A
1
2B 510C
Evaluate ( AB)C and A( BC ). Check that you get the same matrix.
Answer: We have
21
AB
so
105
21
00
51021
C)AB(
On the other hand, we have
5
10
1
2
0
0)BC(
so
10
5
2
1
0
0
5
10
1
2
0
0
01
10)BC(A
-
8/9/2019 Mathematics and Computation
20/47
Example. Consider the matrices
11
21A
11
21B
Then it is easy to check that
AB = I 2 and BA = I 2
The identity matrix behaves like the number 1 not only among the matrices of the form nxn.Indeed, for any nxm matrix A, we have
InA = A and AI m =A
3.2 Procedure to solve simultaneous equation with a matrix system
An important use of matrix theory is the solution problem with more than two unknownvariables and because the method is based on strict rules, it is suitable for use in computer
programs. Consider how three simultaneous equations are presented as a vector. The Matrix Ais called the Coefficient matrix and it is formed from an array of numbers made from thecoefficients a 11 , a12,
The column vector b is made from the coefficients b 1, b 2,.and the column vector X is madeup from the variables, x, y, and z
The column vector b is the product of matrix A and X
a11x+a 12y+a 13z =b 1
a21x+a 22y+a 23z =b 2
a31x+a 32y+a 33z =b 3
We write this as AX = b
Definition:
Suppose that we had a matrix B such that AB = I (The unit matrix), we then could state as:
ABX = IX = Bb , X = Bb
This gives a numerical solution for X. the problem is finding the matrix B such that AB = I.
This matrix is called the inverse matrix and we need to understand the following section inorder to determine the inverse matrix.
Column vectors
X bA
-
8/9/2019 Mathematics and Computation
21/47
3.3 Determinants
The determinant of a matrix is a single number that results from performing a specificoperation on the array. It will be used later to solve simultaneous equations. The determinant
of a matrix A is denoted by det A or A. The rule for finding the determinant can onlyapplied to a square matrix and the following is an explanation for it.
For a 2x2 array the determinant is found as follows.
2221
1211
aa
aaAdet
A=a11*a22 - a12*a21
An important point to remember is that the determinant of all unit matrix is 1
For larger square arrays, the rule for finding the determinant is more complicated and it iscrucial to understand the following in order to do it.
3.4 Minors and Cofactors
If we cross out one row and one column of a matrix and find the determinant of the remainingarray, we have the minor. The minor is designated M and the subscript is the number of therow and the column eliminated
333231
232221
131211
aaa
aaa
aaa
3332
23221111 aa
aadetAM
The cofactor is numerically the same as the minor but it changes sign for every position in theraw or column and the change in sign is indicated by the pattern shown. This is designatedwith a letter corresponding to the elements so in this case the minor would be A 32 and fromthe sign patter we find A 32 = M 32
-
8/9/2019 Mathematics and Computation
22/47
Consider how we find the determinant of the following 3x3 matrix
333231
232221
131211
aaa
aaa
aaa
A
STEP 1Put a line through row 1 and column 1 leaving the elements shows.Find the determinant of the 2x2 array enclosed in the square. Thisis called the MINOR of a11 and designated by M11The COFACTOR is A 11 = M 11
333231
232221
131211
aaa
aaa
aaa
STEP 2Put a line through row 1 and column 2 leaving the elements shown.From these into a 2x2 array and find the determinant. The result is
the Minor M12. The COFACTOR is A 12 = -M 12 333231
232221
131211
aaa
aaa
aaa
STEP 3Put a line through row 1 and column 3 leaving the elements shown.From these into a 2x2 array and find the determinant. The result isthe Minor M13.The COFACTOR is A 13 = M 13 The determinant of the whole array is now found from:
A=a11A11+a12A12+a13A13 333231
232221
131211
aaa
aaa
aaa
For larger arrays the method is the same but the process is repeated until we left with a 2x2array. The cofactors takes one the sign as indicated by the elements position shown below
-
8/9/2019 Mathematics and Computation
23/47
3.5 Adjoint matrix
Another concept used in matrix methods is the adjoint or adjugate matrix. This has veryuseful properties in the solution of problems. This is a matrix formed from all the cofactors ofthe original matrix and then transposed. We designate this adj
If we had 3x3 matrix designated A, the adjoint is given as
T
333231
232221
131211
333231
232221
131211
AAAAAAAAA
adjA,aaaaaaaaa
A
3.6 Inverse matrix
We are in the last stage now and next we will be able to solve system of equations. Supposewe had two matrices A and B such that the product is the unit matrix, i.e
AB = I and it follows that BA = I
Matrix B is the inverse of matrix A so we denote it A -1 and replace B with this, so AA -1 =I
We have already used the relationship A adj A =AI
So equating we have A adj A = AAA-1
This result: A-1= (adj A)/ A
Where, the determinant is not equal to zero.
Example: For a square matrix of order 2, we have
ac bd
a bcd
dc ba
adjT
which gives
ac bd
bcad1
dc ba
1
-
8/9/2019 Mathematics and Computation
24/47
Example solving with inverse matrices
Let
22
32A and
112/31
B
One may easily check that 2I10
01BAAB
Hence A is invertible and B is its inverse.
Notation. A common notation for the inverse of a matrix A is A-1. So
AA -1 = A -1 A = I n
Example. Find the inverse of
21
11A
Write
dc
baA 1
Since 21 I
d2 bc2ad bcaAA
we get
1d2 b
0d b
0c2a
1ca
Algebraic manipulations give
32
a 31
b 31
c 31
d
or
3
1
3
131
32
A 1
-
8/9/2019 Mathematics and Computation
25/47
The inverse matrix is unique when it exists. So if A is invertible, then A-1 is also invertible and
AA 11
The following basic property is very important: If A and B are invertible matrices, then AB isalso invertible and
111 ABAB
-
8/9/2019 Mathematics and Computation
26/47
4 Modeling via Differential Equations
One of the most difficult problems that a scientist deals with in his everyday research is:"How do I translate a physical phenomenon into a set of equations which describes it?''
It is usually impossible to describe a phenomenon totally , so one usually struggle for a set ofequations which describes the physical system approximately and adequately .
In general, once we have built a set of equations, we compare the data generated by theequations with real data collected from the system (by measurement). If the two sets of data"agree'' (or are close), then we gain confidence that the set of equations will lead to a gooddescription of the real-world system. For example, we may use the equations to make
predictions about the long-term behavior of the system. It is also important to keep in mindthat the set of equations stays only "valid" as long as the two sets of data are close. If a
prediction from the equations leads to some conclusions which are by no means close to thereal-world future behavior, then we should modify and "correct" the underlying equations. Asyou can see, the problem of generating "good" equations is not an easy exercise.
Note that the set of equations is called a Model for the system.
How do we build a Model?
The basic steps in building a model are:
Step 1: Clearly state the assumptions on which the model will be based. These
assumptions should describe the relationships among the quantities to be studied.
Step 2: Completely describe the parameters and variables to be used in the model.
Step 3: Use the assumptions (from Step 1) to derive mathematical equations relatingthe parameters and variables (from Step 2).
4.1 First order differential equation
Examples of first order differential linear equations with constant coefficients included:exponential growth, modelling examples including radioactive decay and time delay equation.
A first order linear differential equation has the following form:
)x(qy)x( pdx
dy
The general solution is given by
)x(u
Cdx)x(q)x(uy
-
8/9/2019 Mathematics and Computation
27/47
where
dx)x( pexp)x(u
called the integrating factor . If an initial condition is given, it can be used to find theconstant C .
Here are some practical steps to follow:
1. If the differential equation is given as
)x(cy)x( bdx
dy)x(a
Rewrite it in the form
)x(qy)x( pdx
dy
where
)x(a)x( b
)x( p and )x(a
)x(c)x(q
2. Find the integrating factor
dx)x( pe)x(u
3. Evaluate the integral
dx)x(q)x(u
4. Write down the general solution
)x(u
Cdx)x(q)x(uy
5. If you are given an IVP, use the initial condition to find the constant C .
Example: Find the particular solution of:
2)0(y,)x(cosy)xtan(y 2'
Solution: Let us use the steps:
-
8/9/2019 Mathematics and Computation
28/47
Step 1: There is no need for rewriting the differential equation. We have
)xtan()x( p
)x(cos)x(q 2
Step 2: Integrating factor
)xsec(eee)x(u ))xln(sec())xln(cos(dx)xtan(
Step 3: We have
)xsin(dx)xcos(dx)x(cos)xsec( 2
Step 4: The general solution is given by
)xcos(C)xsin()xsec( C)xsin(y
Step 5: In order to find the particular solution to the given IVP, we use the initialcondition to find C . Indeed, we have
y(0) = C =2
Therefore the solution is
)xcos(2)xsin(y
Application
1 Radioactive decay modeling
Many radioactive materials disintegrate at a rate proportional to the amount present. Forexample, if X is the radioactive material and Q(t ) is the amount present at time t , then the rateof change of Q(t ) with respect to time t is given by
rQdtdQ
where r is a positive constant ( r >0). Let us call Q(0) = Q 0 the initial quantity of the material X , then we have
rt0eQ)t(Q
-
8/9/2019 Mathematics and Computation
29/47
Clearly, in order to determine Q(t ) we need to find the constant r . This can be done usingwhat is called the half-life T of the material X . The half-life is the time span needed todisintegrate half of the material. So, we have Q(T) = Q o. This gives rT = ln(2).
Therefore, if we know T , we can get r and vice-versa. For example, the half-life of Carbon-14is 5568 +/-30years. Therefore, the constant r associated with Carbon-14 is r =1.24410 -4. As aside note, Carbon-14 is an important tool in the archeological research known as radiocarbondating .
Example: A radioactive isotope has a half-life of 16 days. You wish to have 30 g at the endof 30 days. How much radioisotope should you start with?
Solution: Since the half-life is given in days we will measure time in days. Let Q(t ) be theamount present at time t and Q o the amount we are looking for (the initial amount). We know
that
rt0eQ)t(Q
where r is a constant. We use the half-life T to determine r . Indeed, we have
)2ln(16
1)2ln(
T
1r
Hence, since 30r 0eQ30)30(Q
we get g04.110e30Q)2ln(
16
30
0
2 Population Dynamics modeling
Here are some natural questions related to population problems:
What will the population of a certain country be in ten years?
Given that the rate of change of the population is proportional to the existing population. Inother words, if P (t ) measures the population, we have
kPdtdP
where the rate k is constant. It is fairly easy to see that if k > 0, we have growth, and if k
-
8/9/2019 Mathematics and Computation
30/47
if k >0, then the population grows and continues to expand to infinity, that is,o Lim P(t) (as r goes to infinity) = +infinity
if k
-
8/9/2019 Mathematics and Computation
31/47
Example: Undamped System
If there is no external force applied on the system, f(t) = 0, the system will experience freevibration . Motion of the system will be established by an initial disturbance (i.e. initialconditions). Furthermore, if there is no resistance or damping in the system,c v =0, the
oscillatory motion will continue forever with a constant amplitude. Such a system is termedundamped and is shown in the following figure
Solution for Undamped Systems
The equation of motion derived can be simplified to,
0kxx.m..
With the initial conditions,
o
.o
)0t(x
x)0t(x
This equation of motion is a second order, homogeneous, ordinary differential equation(ODE). If the mass and spring stiffness are constants, the ODE becomes a linearhomogeneous ODE with constant coefficients and can be solved by the CharacteristicEquation method. The characteristic equation for this problem is,
0k s.m 2
which determines the 2 independent roots for the undamped vibration problem. The finalsolution (that contains the 2 independent roots from the characteristic equation and satisfiesthe initial conditions) is,
tsindtcosd)t(x n2n1
tsintcosx)t(x nn
ono
The natural frequency n is defined by,
mk
n
km
xlo
-
8/9/2019 Mathematics and Computation
32/47
and depends only on the system mass and the spring stiffness (i.e. any damping will notchange the natural frequency of a system).
Alternatively, the solution may be expressed by the equivalent form,
)tcos(A)t(x ono
where the amplitude A0 and initial phase 0 are given by,
2
n
o2oo xA
no
o1
o xtan
Sample Time Behavior
The displacement plot of an undamped system would appear as,
Please note that an assumption of zero damping is typically not accurate. In reality, there almost always exists some resistance in vibratory systems. This resistance will damp thevibration and dissipate energy; the oscillatory motion caused by the initial disturbance willeventually be reduced to zero. This type of problem will not be studied here.
-
8/9/2019 Mathematics and Computation
33/47
4.3 Numerical solution methods
4.3.1 Newton-Raphons non-linear root finding
Root finding in one dimension
Consider the Taylor Series expansion of f ( x) about some point x = x0:
f(x) = f(x 0) + (x-x 0)f'(x 0) + (x-x 0)2f"(x 0) + O(|x-x 0|
3).
Setting the quadratic and higher terms to zero and solving the linear approximation of f ( x) = 0 for x gives
)x(f
)x(f xx
n'
001
Subsequent iterations are defined in a similar manner as
)x(f )x(f
xxn
'n
n1n
Geometrically, xn+1 can be interpreted as the value of x at which a line, passing through the point (xn,f(x n)) and tangent to the curve f(x) at that point, crosses the y axis. Figure provides a
graphical interpretation of this
Figure3: Graphical interpretation of the Newton Raphson algorithm.
-
8/9/2019 Mathematics and Computation
34/47
Example 1. Let us approximate the only solution to the equation
x = cos(x)
In fact, looking at the graphs we can see that this equation has one solution.
This solution is also the only zero of the function f(x) = x-cos(x) . So now we see how Newton's method may be used to approximate r . Since r is between 0 and /2, we set x1 = 1.The rest of the sequence is generated through the formula
)xsin(1)xcos(x
x)x(f )x(f
xxn
nnn
n'
nn1n
We havex1 1x2 0,75036386784024400x3 0,73911289091136200x4 0,73908513338528400x5 0,73908513321516100x6 0,73908513321516100x7 0,73908513321516100x8 0,73908513321516100
-3
-2
-1
0
1
2
3
-3 -2 -1 0 1 2 3
x
cos (x)
-
8/9/2019 Mathematics and Computation
35/47
Example 2 Let us find an approximation to 5 to ten decimal places.
Note that 5 is an irrational number. Therefore the sequence of decimals which defines 5will not stop. Clearly 5x is the only zero of f ( x) = x2 - 5 on the interval [1,3]. See thePicture.
Let nx be the successive approximations obtained through Newton's method. We have
n
2n
nn
'n
n1nx2
5xx
)x(f
)x(f xx
Let us start this process by taking x1 = 2.
It is quite remarkable that the results stabilize for more than ten decimal places after only 5iterations!
-6
-4
-2
0
2
4
6
0 0.5 1 1.5 2 2.5 3
x1 2
x2 2,25x3 2,23611111111111000x4 2,23606797791580000x5 2,23606797749979000x6 2,23606797749979000
-
8/9/2019 Mathematics and Computation
36/47
4.3.2 Numerical intergration
4.3.2.1 Simpson
In numerical analysis, Simpson's rule is a method for numerical integration, the numerical
approximation of definite integrals. Specifically, it is the following approximation:
b
a
b f ba
f a f ab
dx x f )(2
4)(6
)()( .
The method is credited to the mathematician Thomas Simpson
Simpsons 1/3 Rule for Integration- Examples
Example 1 Electrical Engineering
For an oscillator to have its frequency within 5% of the target of 1 kHz, the likelihood of thishappening can then be determined by finding the total area under the normal distribution forthe range in question:
dxe2
1f 2
x9.2
15.2
2
a) Use Simpsons 1/3 Rule to find thefrequency.
Solution
a)
) b(f 2
baf 4)a(f
6
a bf
15.2a
9.2b
37500.02
ba
-
8/9/2019 Mathematics and Computation
37/47
2
2
2
1)(
x
e x f
215.2 2
2
115.2 e f
039550.0
29.2 2
2
19.2 e f
0059525.0
2
375.0 2
21375.0 e f
37186.0
) b(f 2
baf 4)a(f
6
a bf
9.237500.0415.26
15.29.2( f f f
0059525.037186.04039550.0605.5
2902.1
4.3.2.2 Trapezium rule
The trapezoidal rule (also known as the trapezoid rule or trapezium rule ) is anapproximate technique for calculating the definite integral
b
a
dx)x(f
Figure: Graphical interpretation of the trapezium rule.
-
8/9/2019 Mathematics and Computation
38/47
The trapezoidal rule works by approximating the region under the graph of the function f ( x) asa trapezoid and calculating its area. It follows that
b
a 2
) b(f )a(f )a b(dx)x(f
In general, suppose we need to integrate from x0 to x1. We shall subdivide this interval into n steps of size x=(x 1-x0)/n as shown in figure.
Example 1 Chemical Engineering
A very simplified model of the reaction developed suggests a functional relation in an integralform. To find the time required for 50% of the oxygen to be consumed, the time, sT isgiven by
dx x
xT
6
6
1061.0
1022.1 11
7
10316.2103025.473.6
a) Use single segment Trapezoidal rule to find the time required for 50% of the oxygento be consumed.
b) Find the true error, t E , for part (a).
c) Find the absolute relative true error, t , for part (a).
Solution
a) 2
b f a f ab f , where
61022.1 a
61061.0 b
x x
x f 117
10316.2
103025.473.6)(
11
611
766 100581.3
1022.110316.2
103025.41022.173.61022.1 f
11
611
766 102104.3
1061.010316.2
103025.41061.073.61061.0 f
-
8/9/2019 Mathematics and Computation
39/47
2
102104.3100582.31022.11061.0
111166 f
s109119.1 5
b) The exact value of the above integral is,
dx x
xT
6
6
1061.0
1022.1 11
7
10316.2
103025.473.6
s109014.1 5
so the true error is
Valuee Approximat ValueTrue E t
55 109119.1109014.1
2.1056
c) The absolute relative true error, t , would then be
100ValueTrue
Error Truet 100
109014.1
2.10565
%55549.0
4.3.3 Numerical differentiation
4.3.3.1 Numerical Eulers solution methods
Consider a first order differential equation of the form )y,t(f
dt
dy
subject to some boundary/initial condition f (t =t 0) = c. The finite difference solution of thisequation proceeds by discretising the independent variable t to t 0, t 0+ t , t 0+ 2 t , t 0+ 3 t , We shall denote the exact solution at some t = t n = t 0+n t by yn = y (t=t n) and our approximatesolution by Y n. We then look to solve
Y' n = f (t n,Y n)
-
8/9/2019 Mathematics and Computation
40/47
The Euler method is the simplest finite difference scheme to understand and implement. Byapproximating the derivative in as
Y' n ~ (Y n+1 - Y n)/ t
in our differential equation for Y n we obtain
Yn+1 ~ Y n + tf(t n,Yn).
Given the initial/boundary condition Y 0 = c, we may obtain Y 1 from Y 0 + tf (t 0,Y 0), Y 2 fromY 1 + tf (t 1,Y 1) and so on, marching forwards through time. This process is shown graphicallyin figure .
Sketch of the function y(t ) (dark line) and the Euler method solution (arrows). Each arrow istangental to to the solution of passing through the point located at the start of the arrow. Notethat this point need not be on the desired y(t ) curve.
Example 1The concentration of salt x in a homemade soap maker is given as a function of time by
x
dt dx
5.35.37
At the initial time, 0t , the salt concentration in the tank is 50 g/L. Using Eulers methodand a step size of min5.1h , what is the salt concentration after 3 minutes?
Solution
xdt dx
5.35.37
x xt f 5.35.37,
The Eulers method reduces to
h xt f x x iiii ,1
-
8/9/2019 Mathematics and Computation
41/47
For 0i , 00 t , 500 x
h xt f x x 0001 ,
5.150,050 f
5.1)50(5.35.3750
5.15.13750
g/L25.156
1 x is the approximate concentration of salt at
ht t t 01 5.10 min 5.1
g/L25.1565.1 1 x x
For 1i , 5.11 t , 25.1561 x
h xt f x x 1112 , 5.125.156,5.125.156 f
5.1)25.156(5.35.3725.156 5.138.58425.156
g/L31.720
2 x is the approximate concentration of salt at
ht t t 12 5.15.1 min 3
g/L31.7203 2 x x
Figure 1 compares the exact solution with the numerical solution from Eulers method forstep size of 5.1h .
-
8/9/2019 Mathematics and Computation
42/47
Figure 1 Comparing exact and Eulers method
The problem was solved again using smaller step sizes. The results are given below in Table1.
Table 1 Concentration of salt at 3 minutes as a function of step size, h .
stepsize,h
3 x t E %|| t
3483.0
6622.2
2556.5
0.023249
0.010082
Figure 2 shows how the concentration of salt varies as a function of time for different stepsizes.
-
8/9/2019 Mathematics and Computation
43/47
Figure 2 Comparison of Eulers method with exact solution for different step sizes
The exact solution of the ordinary differential equation is given by
t et x 5.3286.39714.10)(
The solution to this nonlinear equation at min3t is
g/L 715.10)3( x
-
8/9/2019 Mathematics and Computation
44/47
4.3.4 Curve fitting
This section presents both the theory of curve fitting and compute methods using Excel
4.3.4.1 Linear , polynomical, exponential and power
Curve fitting - capturing the trend in the data by assigning a single function across the entirerange.The example below uses a straight line function
A straight line is described by f(x) = ax+b
The goal is to identify the coefficients a and b such that f(x) fitsthe data well Quantifying the error in the curve fit
Assumption
1) Positive or negative error have the same value (data point is above or below the line)
244
233
222
211
sint po.data#
1i
2i ))x(f y())x(f y())x(f y())x(f y()d(error
Our fit is a straight line, so now substitute f(x) = ax + b
s podata
iii
s podata
iii bax y x f yerror
int.#
1
2int.#
1
2 ))(())((
The best fit line has a minimum error between the line and data points. This is called the leastsquare approach, since we minimize the square of the error.
Minimizing the error
n
1iiii 0) baxy(x2a
)error (
(x4 , f(x4))
(x2 , f(x2))(x3 , f(x3))
(x1 , f(x1))
(f(x) = ax+b
-
8/9/2019 Mathematics and Computation
45/47
n
1iii 0) baxy(2 b
)error (
Solve for the a and b so that the previous two equations both =0
Rewrite these two equations
iii2i yxx bxa
ii yn* bxa
ii
i2ii
i
yx
y
a
b
xx
xn
We have the data points (xi, yi) for all i = 1..n, so we have all the summation terms in thmatrix form.
The unknowns are a and b
We already knows how to solve matrix
2ii
i
xx
xnA
a
bX
ii
i
yx
yB
AX = B
Using matlab, the coefficients a and b can be solved using matrix inversion
>> X = A -1*B
Note: A, B and X are not the same as a, b and x
Let us test this with an example:
I 1 2 3 4 5 6X 0 0.5 1 1.5 2 2.5Y 0 1.5 3 4.5 6 7.5
First we find values for all the summation terms, n =6
5.7x i , 5.22y i 75.13x 2i , 25.41yx ii
Now plugging into the matrix form gives us:
-
8/9/2019 Mathematics and Computation
46/47
25.41
5.22
a
b
75.135.7
5.76
25.415.22
*75.135.75.76
inva
b
The solution is
30
a b
f(x) = 3x+0
This fits the data exactly. That is, the error is zero. Usually this is not the outcome. Usuallywe have data that doesnt exactly fit a straight line.
Example 2
Here is an example with some noisy data
x = [ 0 .5 1 1.5 2 2.5],
y = [-0.4326 -0.1656 3.1253 4.7877 4.8535 8.6909]
6584.418593.20
a b
75.135.75.76
6584.41
8593.20*
75.135.7
5.76inv
a
b
561.3975.0
a b
So our fit is f(x) = 3.561 x 0.975
-
8/9/2019 Mathematics and Computation
47/47
The following figures shows data fitting with Excel
Figure: Linear regression (trend) fitting for the data given in Example 2
y = 3.5621x - 0.9761R = 0.9334
-2
0
2
4
6
8
10
0 0.5 1 1.5 2 2.5 3
Y
X
x
Linear (x)
y = 0.3537x 2 + 2.6779x - 0.6814R = 0.9383
-2
0
2
4
6
8
10
0 0.5 1 1.5 2 2.5 3
Y
X
x
Poly. (x)