You are on page 1of 47

Basic Mathematics

MSc Petroleum Engineering

University of UMSA
La Paz
April 08-26, 2013
Mesfin Belayneh
UoS, Norway

Contents
1 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

1 Introduction
All fields of studies (Science and Engineering) use mathematics. The language of
mathematics is a tool to formulate theories based on experimental observations. Therefore, in
this 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

2 Vector algebra

A vector is used to represents a physical quantity that has both a direction and magnitude, for
example, 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 its
direction 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. It
demonstrates that the sum of two vectors is independent of the order in which the vectors are
added. 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

W
U

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 pU. It follows that:

p(qU) = (pq)U
(p + q)U = pU + qU
p(U + V) = pU + pV

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.

2U

-U

Multiplication of U with scalar


A vector 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 expressed
as a product of their magnitude and unit vectors, i and j.
U = Uxi and Uyj
Similarly, in three dimensional system, we can write
U = Uxi + Uyj + 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

U U 2x U 2y U 2z
Ux=Uxi
Uy=Uyj
U=Uxi +Uyj

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 help
solve static problems with multiple forces. Force is a vector quantity, having both magnitude
and 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 applied
forces produces no external effects.

When there are two concurrent forces applied to a body a single resultant force can be used to
represent the two forces by applying the addition law for vectors (i.e. parallelogram law). The
use of trigonometry based on the law of sine and cosine can also be helpful in solving
problems involving two force vectors.
C

b
a

Law of sines:
a
b
c

sin sin sin

Law of cosine:

b 2 a 2 c 2 2ac cos
Fig. 4 Law of sines and cosine
However, if there are more than two forces present, the standard method to solve a problem is
reduce 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 the
figure on the left. The resolved force can be written in Cartesian form:
F = Fxi + Fyj
F = Fcosi + Fsinj

F Fx2 Fy2
A force that is resolved (decomposed) into its rectangular components in the x, y, and z-axis
can be expressed in the following Cartesian form:
F = Fxi + Fyj + Fzk
F = Fcosxi + Fcosyj + Fcoszk

F Fx2 Fy2 Fz2

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 + Uyj + Uzk) (Vxi + Vyj + Vzk)
U = UxVx + UyVy + UzVz
Dot product has the following properties:

Commutative law:
Associative law:
Distributive law:

U .V = V .U
q(U . V) = (qU) . V = U . (qV)
U .(V + W) = U . V + U . W

U . V = |U| |V| cos


Fig. 6 Dot product of U and V

Figure 7 Example work done by a force at an angle


F2

F1

S
W= F1 .S +F2 .S = |F1| |S| cos +|F2| |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 to
have 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


UxV=W

V x U = -W

In general, cross products have the following properties:


Does not follow the commutative law:

U x V = -(V x U)
Satisfies associative law:

q(U x V) = (q U) x V = U x (qV)
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 the
force to rotate the body about a point or axis. This tendency is known as a moment. The point
or axis about which the rotation takes place is referred to as the moment center. Moments are
usually 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 perpendicular
distance, d, measured from the point or axis where the force is applied. The perpendicular
distance is also known as the moment arm.
In practice, the moment is considered to be positive if the resultant rotation is
counterclockwise. Negative moments generate clockwise rotation. A moment is a vector
quantity, having both magnitude and direction.

F
d

Moment = Fd

Referring to the figure shown on the left, the moment about point O caused by the applied
force 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 1800
Mo=dF
The direction of the rotation can be determined using the Right Hand Rule

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:
ixi=0

ixj=k

i x k = -j

j x i = -k

jxj=0

jxk=i

kxi=j

k x j = -i

kxk=0

For a vector U = Uxi + Uyj + Uzk and a vector V = Vxi + Vyj + Vzk, the determinant of U and
V can be written as:
i
UxV U x
Vx

j
Uy
Vy

k
Uz
Vz

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 = r2-r1
= (x2 - x1)i + (y2 - y1)j + (z2 - z1)k

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 = rxi + ryj
F = Fxi + Fyj

Mo = r x F
i
M o rxF rx
Fx

j
ry
Fy

k
0
0

= (rxFy - ryFx)k
= Mzk

Fig. 11: The two dimensional force

For a three dimensional case, there are three vector components.


i
M o rxF rx
Fx

j
ry
Fy

k
rz
Fz

= (ryFz - rzFy)i + (rzFx - rxFz)j + (rxFy - ryFx)k


= Mxi + Myj + Mzk

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

Example: Moment and Force Equilibrium


A body or an object is said to be in equilibrium when the resultant moment and force vectors
are equal to zero.
Fx = 0

Fy = 0

Fz = 0

Mx = 0

My = 0

Mz = 0

Example 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 70o = -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:
r1/O= (5.00 i + 10.00 j) m
r2/O= (-5.00 i + 10.00 j) m
Using the following equation:

i
M o rxF rx
Fx

j
ry
Fy

k
0
0

= (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:
rO/A = 500 i + 700 j - 150 k
Using the following equation:
i
M o rxF rx
Fx

j
ry
Fy

k
rz
Fz

= (ryFz - rzFy)i + (rzFx - rxFz)j + (rxFy - ryFx)k


= Mxi + Myj + Mzk

MAO = [(700)(834) - (-150)(531) i .+ (-150)(152) - (500)(834) j + (500)(531) - (700)(152) k]


lb.in.
MAO = (663.5x103i - 439.8x103j + 159.1x103k) lb-in.

3 Matrix algebra
In mathematics we have many ways of expressing numbers and each method use its own rules
of manipulation (algebra). For example, vector algebra is quite different but logical and very
useful 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 quite
complex. It will help if you have studied vector theory. In order to fully understand matrix
theory, 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 solve
simultaneous 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 is
designated by a letter followed a row and column as shown. The matrix shown might be
labeled as A and all the elements as a.
Columns

The size of the array is always stated as:


The number of rows x number of columns
The one shown here is a 3x3 matrix

3.1.2 Transposed matrix


This is a matrix in which row 1 becomes column 1; row 2 becomes column 2 and so on. The
transpose of matrix A is designated as AT. An example is shown below.
2 5 7
A

4 8 3

2 4
A 5 8
7 3
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 so
the variables line up in columns and then add the coefficients.
2x+3y+5z
3x+4y-2z
5x+7y+3z

Add

To show this a matrix operation we would write the following. In other words we simply add
or subtract the elements in the same position in each array. So it follows that the arrays must
be the same size.

x
x
x
2 3 4 y 3 4 2 y 5 7 2 y
z
z
z
We add and subtract two matrices, we dont need to write in the column vector as it is the
same for each part so we only need to write

3 4 3 4 2 5 7 2

Example
Add and subtract the two arrays as shown

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

a 11 a 12 a 13 a 11 a 12 a 13
a 21 a 22 a 23 a 21 a 22 a 23
a 31 a 32 a 33 a 31 a 32 a 33
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.
Column vectors

A=
X

We want the result to be three equations


a11x+a12y+a13z =b1
a22x+a22y+a23z =b2
a31x+a32y+a33z =b3

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 two
arrays the rule is more complex.

Array multiplication
Consider how we multiply an array A by another B to obtain a new array C

a
a
A 11 12
a 21 a 22

b
b
B 11 12
b 21 b 22

c
c
AB C 11 12
c 21 c 22

Each element in C is obtained as follows

c11 a11b11 a12b 21


c12 a11b12 a12b 22
c 21 a 21b11 a 22b 21
c 22 a 21b12 a 22b 22
This is the general rule. Note that a row x column produces a row. For element c11, take the
first row of A and multiply by the first column of B

a 11

b
a 12 11 a 11b11 a 12 b 21
b 21

For element c12, take the first row of A and multiply by the second column of B

a 11

b
a 12 12 a 11b12 a 12b 22
b 22

For element c21, take the second row of A and multiply by the first column of B

a 21

b
a 22 11 a 21b11 a 22b 21
b 21

For element c22, take the second row of A and multiply by the second column of B

a 21

b
a 22 12 a 21b12 a 22b 22
b 22

Collecting all

a b a b
a b a b
C 11 11 12 21 11 12 12 22
a 21b11 a 22b 21 a 21b12 a 22b 22

The rule may be summarized as follows and extended to larger arrays

Row.1xCol .1 Row.1xCol .2
C

Row.2xCol .1 Row.2xCol .2

Other rules
It can be shown that the normal rules of multiplication may be observed if the orders of
matrices 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= BTAT

Example: Consider the matrices

0 1

A
1 0

2
B
1

C 0 1 5

Evaluate (AB)C and A(BC). Check that you get the same matrix.
Answer: We have

1
AB
2
so

1
0 1 5

(AB)C 0 1 5
2
0 2 10
On the other hand, we have

0 2 10

(BC)
0

so

0 1 0 2 10 0 1 5

A(BC)
1 0 0 1 5 0 2 10

Example. Consider the matrices

2
1

1 2

B
1
1

Then it is easy to check that


AB = I2 and BA = I2

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 AIm =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 unknown
variables 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 A
is called the Coefficient matrix and it is formed from an array of numbers made from the
coefficients a11, a12,
The column vector b is made from the coefficients b1, b2,.and the column vector X is made
up from the variables, x, y, and z
The column vector b is the product of matrix A and X
Column vectors

a11x+a12y+a13z =b1
a21x+a22y+a23z =b2
a31x+a32y+a33z =b3
We write this as AX = b
A

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 in
order to determine the inverse matrix.

3.3 Determinants

The determinant of a matrix is a single number that results from performing a specific
operation 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 only be
applied to a square matrix and the following is an explanation for it.
For a 2x2 array the determinant is found as follows.

a
det A 11
a 21

a 12
a 22

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 is
crucial 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 remaining
array, we have the minor. The minor is designated M and the subscript is the number of the
row and the column eliminated

a 11
a
21
a 31

a 12
a 22
a 32

a 13
a 23
a 33

a
M11 A11 det 22
a 32

a 23
a 33

The cofactor is numerically the same as the minor but it changes sign for every position in the
raw or column and the change in sign is indicated by the pattern shown. This is designated
with a letter corresponding to the elements so in this case the minor would be A32 and from
the sign patter we find A32 = M32

Consider how we find the determinant of the following 3x3 matrix

STEP 1
Put a line through row 1 and column 1 leaving the elements shows.
Find the determinant of the 2x2 array enclosed in the square. This
is called the MINOR of a11 and designated by M11
The COFACTOR is A11 = M11

a 11 a 12 a 13
A a 21 a 22 a 23
a 31 a 32 a 33
a 11 a 12 a 13
a

21 a 22 a 23
a 31 a 32 a 33

STEP 2
Put 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 A12 = -M12

a 11
a
21
a 31

STEP 3
Put a line through row 1 and column 3 leaving the elements shown.
From these into a 2x2 array and find the determinant. The result is
the Minor M13.
The COFACTOR is A13 = M13
The determinant of the whole array is now found from:
A=a11A11+a12A12+a13A13

a 11
a
21
a 31

a 12
a 22
a 32

a 12
a 22
a 32

a 13
a 23
a 33
a 13
a 23
a 33

For larger arrays the method is the same but the process is repeated until we left with a 2x2
array. The cofactors takes one the sign as indicated by the elements position shown below

3.5 Adjoint matrix

Another concept used in matrix methods is the adjoint or adjugate matrix. This has very
useful properties in the solution of problems. This is a matrix formed from all the cofactors of
the original matrix and then transposed. We designate this adj
If we had 3x3 matrix designated A, the adjoint is given as

a 11 a 12 a 13
A11 A12
A a 21 a 22 a 23 , adjA A 21 A 22
a 31 a 32 a 33
A 31 A 32

A13
A 23
A 33

3.6 Inverse matrix

We are in the last stage now and next we will be able to solve system of equations. Suppose
we 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

a b d c d b

adj
c d b a c a
T

which gives
1

a b
1 d b

ad bc c a
c d

Example solving with inverse matrices


Let

2 3
1 3 / 2
and B

A
2
2
1

One may easily check that

1 0
I 2
AB BA
0 1

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-1A = In

Example. Find the inverse of

1 1

A
1 2

Write

Since

a b

A 1
c d
bd
ac
I 2
AA 1
a 2c b 2d

we get

a c 1
a 2c 0

bd0

b 2d 1
Algebraic manipulations give
a

2
3

1
3

or

1
2

3
A 1 3
1
1

3 3

1
3

1
3

The inverse matrix is unique when it exists. So if A is invertible, then A-1 is also invertible and

1 1

The following basic property is very important: If A and B are invertible matrices, then AB is
also invertible and

AB1 B1A 1

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 of
equations which describes the physical system approximately and adequately.
In general, once we have built a set of equations, we compare the data generated by the
equations 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 good
description 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 mind
that 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 the
real-world future behavior, then we should modify and "correct" the underlying equations. As
you 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 relating
the 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:
dy
p( x ) y q ( x )
dx

The general solution is given by

u(x)q(x)dx C
u(x)

where

u(x) exp p(x)dx

called the integrating factor. If an initial condition is given, it can be used to find the
constant C.
Here are some practical steps to follow:
1. If the differential equation is given as
a (x)

dy
b( x ) y c( x )
dx

Rewrite it in the form


dy
p( x ) y q ( x )
dx

where

p( x )

b( x )
c( x )
q( x )
a ( x ) and
a (x)

2. Find the integrating factor

u(x) e p( x )dx
3. Evaluate the integral

u(x)q(x)dx
4. Write down the general solution

u(x)q(x)dx C
u(x)

5. If you are given an IVP, use the initial condition to find the constant C.
Example: Find the particular solution of:
y ' tan(x) y cos 2 (x) ,

Solution: Let us use the steps:

y(0) 2

Step 1: There is no need for rewriting the differential equation. We have

p(x) tan(x)

q(x) cos 2 (x)

Step 2: Integrating factor

u(x) e tan(x )dx e ln(cos(x )) e ln(sec(x )) sec( x)


Step 3: We have

sec(x) cos

(x)dx cos(x)dx sin( x)

Step 4: The general solution is given by


y

sin( x ) C
sin( x ) C cos( x )
sec( x )

Step 5: In order to find the particular solution to the given IVP, we use the initial
condition to find C. Indeed, we have
y(0) = C =2
Therefore the solution is
y sin( x) 2 cos(x)

Application
1 Radioactive decay modeling
Many radioactive materials disintegrate at a rate proportional to the amount present. For
example, if X is the radioactive material and Q(t) is the amount present at time t, then the rate
of change of Q(t) with respect to time t is given by
dQ
rQ
dt

where r is a positive constant (r>0). Let us call Q(0) = Q0 the initial quantity of the material
X, then we have
Q(t ) Q 0 e rt

Clearly, in order to determine Q(t) we need to find the constant r. This can be done using
what is called the half-life T of the material X. The half-life is the time span needed to
disintegrate half of the material. So, we have Q(T) = Qo. This gives rT = ln(2).
Therefore, if we know T, we can get r and vice-versa. For example, the half-life of Carbon-14
is 5568 +/-30years. Therefore, the constant r associated with Carbon-14 is r =1.24410-4. As a
side note, Carbon-14 is an important tool in the archeological research known as radiocarbon
dating.
Example: A radioactive isotope has a half-life of 16 days. You wish to have 30 g at the end
of 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 the
amount present at time t and Qo the amount we are looking for (the initial amount). We know
that

Q(t ) Q 0 e rt
where r is a constant. We use the half-life T to determine r. Indeed, we have
r

1
1
ln( 2) ln( 2)
T
16

Hence, since

Q(30) 30 Q 0 e r 30
30

we get Q 0 30e 16

ln(2 )

110.04g

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. In
other words, if P(t) measures the population, we have
dP
kP
dt

where the rate k is constant. It is fairly easy to see that if k > 0, we have growth, and if k <0,
we have decay. This is a linear equation which solves into
P( t ) P0 e kt

Where Po is the initial population, i.e. P(0) = Po. Therefore, we conclude the following:

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<0, then the population will shrink and tend to 0. In other words we are facing
extinction.

4.2 Second order equations and systems


Many of real life problems are modeled by nonlinear equations. Here we will show how a
second order equation may re-written as a system. The technique developed for the system
may then be used to study second order equation even if they are not linear.
Equation Type and Solution Method
We will focus on linear homogeneous constant coefficient differential equations of second
order, because they are encountered most frequently.
1. The general form is ay+by+cy = 0, where a,b,c are real constants.
This type of equation is very useful in many applied problems (physics, electrical
engineeringetc). Let us summarize step by steps to follow in order to find the general
solution:
2. Write down characteristic equation: Substituting y = ex into the equation leads to the
equation
a2+b +c = 0 for .
This is quadratic equation. Let the solution l and are the roots 1 = 2,

2.1 If the equation has real solutions 1 = 2, then the general solution is
y = c1e1x+ c2e2x
2.2 If the equation has complex solutions 1,2 = u iv, then the general solution is
y = c1eux cos(vx)+ c2eux sin(vx).
2.3 If the equation has only one real solution , then the general solution is
y = c1ex+ c2xex

Example: Undamped System


If there is no external force applied on the system, f(t) = 0, the system will experience free
vibration. Motion of the system will be established by an initial disturbance (i.e. initial
conditions). 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 termed
undamped and is shown in the following figure

k
m

lo

Solution for Undamped Systems


The equation of motion derived can be simplified to,
..

m. x kx 0

With the initial conditions,

x ( t 0) x o
.
x ( t 0) o
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 linear
homogeneous ODE with constant coefficients and can be solved by the Characteristic
Equation method. The characteristic equation for this problem is,

m.s 2 k 0
which determines the 2 independent roots for the undamped vibration problem. The final
solution (that contains the 2 independent roots from the characteristic equation and satisfies
the initial conditions) is,
x(t ) d 1 cos n t d 2 sin n t

x ( t ) x o cos n t

o
sin n t
n

The natural frequency n is defined by,


n

k
m

and depends only on the system mass and the spring stiffness (i.e. any damping will not
change the natural frequency of a system).
Alternatively, the solution may be expressed by the equivalent form,
x( t ) A o cos( n t o )

where the amplitude A0 and initial phase 0 are given by,


2

A o x o
n


o tan 1 o
x o n

2
o

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 the
vibration and dissipate energy; the oscillatory motion caused by the initial disturbance will
eventually be reduced to zero. This type of problem will not be studied here.

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(x0) + (x-x0)f'(x0) + (x-x0)2f"(x0) + O(|x-x0|3).


Setting the quadratic and higher terms to zero and solving the linear approximation of f(x) = 0
for x gives

x1 x 0

f (x 0 )
f ' (x n )

Subsequent iterations are defined in a similar manner as

x n 1 x n

f (x n )
f ' (x n )

Geometrically, xn+1 can be interpreted as the value of x at which a line, passing through the
point (xn,f(xn)) 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.

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.

3
2

x
cos (x)

1
0

-3

-2

-1

-1
-2
-3

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

x n 1 x n

f (x n )
x cos(x n )
xn n
'
1 sin( x n )
f (x n )

We have
x1
x2
x3
x4
x5
x6
x7
x8

1
0,75036386784024400
0,73911289091136200
0,73908513338528400
0,73908513321516100
0,73908513321516100
0,73908513321516100
0,73908513321516100

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 5
will not stop. Clearly x 5 is the only zero of f(x) = x2 - 5 on the interval [1,3]. See the
Picture.
Let x n be the successive approximations obtained through Newton's method. We have

x n 1 x n

f (x n )
x 2n 5

n
2x n
f ' (x n )

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 5
iterations!

6
4
2
0
0

0.5

1.5

-2
-4
-6

x1
x2
x3
x4
x5
x6

2
2,25
2,23611111111111000
2,23606797791580000
2,23606797749979000
2,23606797749979000

2.5

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

f ( x)dx
a

(b a)

a b
f (a) 4 f
f (b) .

6
2

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 this
happening can then be determined by finding the total area under the normal distribution for
the range in question:
2.9

2.15

1
2

x2
2

dx

a) Use Simpsons 1/3 Rule to find the frequency.


Solution
a)

ba
a b
f (a ) 4f
f ( b)

6
2

a 2.15
b 2.9
ab
0.37500
2

f ( x)

f 2.15

x2
2

1
2

2.152
2

0.039550

f 2.9

1
2

2.9 2
2

0.0059525

f 0.375

1
2

0.3752
2

0.37186
f

ba
a b
f (a ) 4f
f ( b)

6
2

(2.9 2.15

f 2.15 4 f 0.37500 f 2.9


6

5.05

0.039550 40.37186 0.0059525


6

1.2902
4.3.2.2 Trapezium rule
The trapezoidal rule (also known as the trapezoid rule or trapezium rule) is an
approximate technique for calculating the definite integral
b

f (x)dx
a

Figure: Graphical interpretation of the trapezium rule.

The trapezoidal rule works by approximating the region under the graph of the function f(x) as
a trapezoid and calculating its area. It follows that
b

f (x)dx (b a)
a

f (a ) f ( b)
2

In general, suppose we need to integrate from x0 to x1. We shall subdivide this interval into n
steps of size x=(x1-x0)/n as shown in figure.

Example 1 Chemical Engineering


A very simplified model of the reaction developed suggests a functional relation in an integral
form. To find the time required for 50% of the oxygen to be consumed, the time, T s is
given by

6.73x 4.3025 10 7

dx
11
1.2210 6
2
.
316

10
x

0.6110 6

a) Use single segment Trapezoidal rule to find the time required for 50% of the oxygen
to be consumed.
b) Find the true error,

Et , for part (a).

c) Find the absolute relative true error, t , for part (a).

Solution
a)

f a f b , where
f b a

a 1.22 10 6
b 0.61 10 6

6.73x 4.3025 10 7
f ( x)

2.316 10 11 x

6.731.22 10 4.3025 10
f 1.22 10
2.316 10 1.22 10

11

11
3.0581 10

6.73 0.61 10 6 4.3025 10 7


11
f 0.61 10 6
3.2104 10
11
6
2.316 10 0.61 10

f 0.61 10

1.22 10

3.0582 1011 3.2104 1011

1.9119 10 5 s

b) The exact value of the above integral is,


6.73x 4.3025 10 7

1.2210 6
2.316 10 11 x

0.6110 6

dx

1.9014 10 5 s

so the true error is


Et True Value Approximate Value
1.9014 105 1.9119 105

1056.2
c) The absolute relative true error, t , would then be
t

True Error
100
True Value

1056.2
100
1.9014 10 5

0.55549 %

4.3.3 Numerical differentiation


4.3.3.1 Numerical Eulers solution methods

Consider a first order differential equation of the form


dy
f ( t , y)
dt

subject to some boundary/initial condition f(t=t0) = c. The finite difference solution of this
equation proceeds by discretising the independent variable t to t0, t0+t, t0+2t, t0+3t,
We shall denote the exact solution at some t = tn = t0+nt by yn = y(t=tn) and our approximate
solution by Yn. We then look to solve
Y'n = f(tn,Yn)

The Euler method is the simplest finite difference scheme to understand and implement. By
approximating the derivative in as
Y'n ~ (Yn+1 - Yn)/t
in our differential equation for Yn we obtain
Yn+1 ~ Yn + tf(tn,Yn).
Given the initial/boundary condition Y0 = c, we may obtain Y1 from Y0 + tf(t0,Y0), Y2 from
Y1 + tf(t1,Y1) and so on, marching forwards through time. This process is shown graphically
in figure.

Sketch of the function y(t) (dark line) and the Euler method solution (arrows). Each arrow is
tangental to to the solution of passing through the point located at the start of the arrow. Note
that this point need not be on the desired y(t) curve.
Example 1
The concentration of salt
dx
37.5 3.5 x
dt

in a homemade soap maker is given as a function of time by

At the initial time, t 0 , the salt concentration in the tank is 50 g/L. Using Eulers method
and a step size of h 1.5 min , what is the salt concentration after 3 minutes?
Solution
dx
37.5 3.5 x
dt
f t, x 37.5 3.5x

The Eulers method reduces to


xi 1 xi f ti , xi h

For i 0 , t0 0 , x0 50
x1 x0 f t 0 , x0 h
50 f 0,501.5
50 37.5 3.5(50)1.5

50 137.51.5

156.25 g/L

x1 is the approximate concentration of salt at


t t1 t0 h 0 1.5 1.5 min
x1.5 x1 156.25 g/L

For i 1 , t1 1.5 , x1 156.25


x2 x1 f t1 , x1 h
156.25 f 1.5,156.251.5
156.25 37.5 3.5(156.25)1.5
156.25 584.381.5
720.31 g/L

x2

is the approximate concentration of salt at


t t 2 t1 h 1.5 1.5 3 min
x3 x2 720.31 g/L

Figure 1 compares the exact solution with the numerical solution from Eulers method for the
step size of h 1.5 .

Figure 1 Comparing exact and Eulers method

The problem was solved again using smaller step sizes. The results are given below in Table
1.
Table 1 Concentration of salt at 3 minutes as a function of step size, h .
step
size,
h

x3

Et

|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 step
sizes.

Figure 2 Comparison of Eulers method with exact solution for different step sizes

The exact solution of the ordinary differential equation is given by


x(t ) 10.714 39.286e 3.5t

The solution to this nonlinear equation at t 3 min is


x(3) 10.715 g/L

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 entire
range.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) fits the 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)

(x4 , f(x4))

(f(x) = ax+b

(x2 , f(x2))
(x3 , f(x3))
(x1 , f(x1))

error

#data.po int s

(d )
i 1

( y1 f ( x 1 )) 2 ( y 2 f ( x 2 )) 2 ( y 3 f ( x 3 )) 2 ( y 4 f ( x 4 )) 2

Our fit is a straight line, so now substitute f(x) = ax + b

error

# data. po int s

( y f ( x ))
i 1

# data. po int s

( y (ax b))
i 1

The best fit line has a minimum error between the line and data points. This is called the least
square approach, since we minimize the square of the error.
Minimizing the error
n
(error )
2 x i ( y i ax i b) 0
a
i 1

n
(error )
2 ( y i ax i b) 0
b
i 1

Solve for the a and b so that the previous two equations both =0
Rewrite these two equations

a x i2 b x i x i y i

a x i b * n yi
n

x i

x
x

i
2
i

b y i

a x i y i

We have the data points (xi, yi) for all i = 1..n, so we have all the summation terms in the
matrix form.
The unknowns are a and b
We already knows how to solve matrix

n
A
x i

x
x

i
2
i

b
X
a

yi
B

x i y i

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
X
Y

1
0
0

2
0.5
1.5

3
1
3

First we find values for all the summation terms, n =6

7.5 , y i 22.5 xi2 13.75 , x i y i 41.25

Now plugging into the matrix form gives us:

4
1.5
4.5

5
2
6

6
2.5
7.5

7.5 b 22.5
6
7.5 13.75 a 41.25

7.5 22.5
b
6
a inv 7.5 13.75 * 41.25

The solution is

b 0
a 3

f(x) = 3x+0
This fits the data exactly. That is, the error is zero. Usually this is not the outcome. Usually
we 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

7.5 b 20.8593
6
7.5 13.75 a 41.6584

7.5 20.8593
b
6
a inv 7.5 13.75 * 41.6584

b 0.975
a 3.561

So our fit is f(x) = 3.561 x 0.975

4.8535 8.6909]

The following figures shows data fitting with Excel

10
y = 3.5621x - 0.9761
R = 0.9334

6
x

Linear (x)
2
0
0

0.5

1.5

-2

2.5

Figure: Linear regression (trend) fitting for the data given in Example 2

10
8

y = 0.3537x2 + 2.6779x - 0.6814


R = 0.9383

6
x

Poly. (x)
2
0
0
-2

0.5

1.5

2.5

Figure: Polynomial (second order) regression fitting for the data given in Example 2

You might also like